From 2932071dd7c357764e2b1ba01f2f2d6eaaae8571 Mon Sep 17 00:00:00 2001 From: John Vincent Bonza Date: Thu, 22 Sep 2022 16:55:58 +0800 Subject: [PATCH] Fix initializing environment object --- src/Core/Application.php | 5 +++-- src/Core/Request.php | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Core/Application.php b/src/Core/Application.php index 2062e1c..8eba216 100644 --- a/src/Core/Application.php +++ b/src/Core/Application.php @@ -15,9 +15,8 @@ class Application { public function __construct($config = []) { - self::$ROOT_DIR = $config['root']; - self::$app = $this; $this->LoadSettings($config); + self::$app = $this; $this->user = null; $this->userClass = $config['userClass']; @@ -40,8 +39,10 @@ public function __construct($config = []) * TODO: Add checking on $config keys before assigning */ 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 diff --git a/src/Core/Request.php b/src/Core/Request.php index 878b906..a04e706 100644 --- a/src/Core/Request.php +++ b/src/Core/Request.php @@ -16,13 +16,13 @@ public function Compose() { switch(Application::$app->config->env->APP_ENV) { case "local": - $path = str_replace(Application::$app->config->app->path->local, "/", $path); + $path = str_replace(Application::$app->config->environment->local, "/", $path); break; case "sandbox": - $path = str_replace(Application::$app->config->app->path->sandbox, "/", $path); + $path = str_replace(Application::$app->config->environment->sandbox, "/", $path); break; case "live": - $path = str_replace(Application::$app->config->app->path->live, "/", $path); + $path = str_replace(Application::$app->config->environment->live, "/", $path); break; } return $path; @@ -30,7 +30,7 @@ public function Compose() { public function GetUrl() { - $path = $this->Composer(); + $path = $this->Compose(); if($path != '/') { $path = str_replace('/', '', $path); @@ -50,7 +50,7 @@ public function GetUrl() public function GetUrlConverted() { - $path = $this->Composer(); + $path = $this->Compose(); if($path != '/') { $path = str_replace('/', '', $path);