Skip to content

Commit fa005a0

Browse files
Merge pull request #9 from infinitybrackets/main
Main
2 parents fb01525 + 3fa7093 commit fa005a0

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Core/Application.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function __construct($config = [])
1919
self::$app = $this;
2020

2121
$this->user = null;
22-
$this->userClass = $config['userClass'];
2322
$this->request = new Request();
2423
$this->response = new Response();
2524
$this->router = new Router($this->request, $this->response);
@@ -40,15 +39,8 @@ public function __construct($config = [])
4039
*/
4140
public function LoadSettings($config) {
4241
self::$ROOT_DIR = $config['root'];
43-
$this->config['app'] = $config['app'];
44-
$this->config['auth'] = $config['auth'];
45-
$this->config['environment'] = $config['environment'];
46-
$this->config['connections'] = $config['connections'];
47-
48-
// Load env file
49-
$dotenv = Dotenv::createImmutable(self::$ROOT_DIR);
50-
$env = $dotenv->load();
51-
$this->config['env'] = $this->ToObject($env);
42+
$this->userClass = $config['auth']['userClass'];
43+
$this->config = $config;
5244

5345
// Transform config type (Array) to (Object)
5446
$this->config = $this->ToObject($this->config);

src/Core/Database.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,17 @@ public function __construct($config = NULL)
2020
$default = NULL;
2121

2222
if(is_string($config)) {
23-
if($config == "ils-local" || $config == "ils-live") {
24-
$default = Application::$app->config->connections->$config;
23+
if($config == "ils") {
24+
switch(Application::$app->config->env->APP_ENV) {
25+
default:
26+
case "local":
27+
$default = Application::$app->config->database->$ils->local;
28+
break;
29+
case "sandbox":
30+
case "live":
31+
$default = Application::$app->config->database->$ils->live;
32+
break;
33+
}
2534
}
2635
}
2736
if(is_null($default)) {

0 commit comments

Comments
 (0)