Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/Core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function __construct($config = [])
self::$app = $this;

$this->user = null;
$this->userClass = $config['userClass'];
$this->request = new Request();
$this->response = new Response();
$this->router = new Router($this->request, $this->response);
Expand All @@ -40,15 +39,8 @@ public function __construct($config = [])
*/
public function LoadSettings($config) {
self::$ROOT_DIR = $config['root'];
$this->config['app'] = $config['app'];
$this->config['auth'] = $config['auth'];
$this->config['environment'] = $config['environment'];
$this->config['connections'] = $config['connections'];

// Load env file
$dotenv = Dotenv::createImmutable(self::$ROOT_DIR);
$env = $dotenv->load();
$this->config['env'] = $this->ToObject($env);
$this->userClass = $config['auth']['userClass'];
$this->config = $config;

// Transform config type (Array) to (Object)
$this->config = $this->ToObject($this->config);
Expand All @@ -70,7 +62,7 @@ public function Run()
echo $this->router->RenderView('layouts/error', [
'message' => $e->getMessage(),
'code' => $errorCode,
'app' => Application::$app->config['app']
'app' => Application::$app->config->app
]);
}
}
Expand All @@ -82,7 +74,7 @@ public function Debug($var) {
}

public function LogError($code, $message) {
$db = new Database(Application::$app->config['env']->APP_ENV == 'local' ? 'ils-local' : 'ils-live');
$db = new Database('ils');
$db->InsertOne("exception_logs", ['code', 'message'], [':in_code' => $code, ':in_message' => $message]);
}

Expand Down
13 changes: 13 additions & 0 deletions src/Core/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ public function GetBody()
return $data;
}

public function GetValue($key = NULL) {
if(is_null($key)) {
return FALSE;
}
$data = $this->GetBody();
if(array_key_exists($key, $data)) {
if(empty($data[$key])) {
return FALSE;
}
return $data[$key];
}
}

/**
* @param $params
* @return self
Expand Down