diff --git a/src/Core/Application.php b/src/Core/Application.php index 8eba216..f20426a 100644 --- a/src/Core/Application.php +++ b/src/Core/Application.php @@ -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); @@ -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); diff --git a/src/Core/Database.php b/src/Core/Database.php index b67e141..7093d16 100644 --- a/src/Core/Database.php +++ b/src/Core/Database.php @@ -20,8 +20,17 @@ public function __construct($config = NULL) $default = NULL; if(is_string($config)) { - if($config == "ils-local" || $config == "ils-live") { - $default = Application::$app->config->connections->$config; + if($config == "ils") { + switch(Application::$app->config->env->APP_ENV) { + default: + case "local": + $default = Application::$app->config->database->$ils->local; + break; + case "sandbox": + case "live": + $default = Application::$app->config->database->$ils->live; + break; + } } } if(is_null($default)) {