From 8c81cc74bea0365f8acf87a9268e582a10e2ad21 Mon Sep 17 00:00:00 2001 From: IvanLuLyf <835498692@qq.com> Date: Sat, 1 Oct 2022 16:11:30 +0800 Subject: [PATCH] rename to initContext --- BunnyPHP/BunnyPHP.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/BunnyPHP/BunnyPHP.php b/BunnyPHP/BunnyPHP.php index cef02ec..11971c3 100644 --- a/BunnyPHP/BunnyPHP.php +++ b/BunnyPHP/BunnyPHP.php @@ -50,7 +50,7 @@ public function run() spl_autoload_register([$this, 'loadClass']); set_error_handler([$this, 'handleErr']); $this->setReporting(); - $this->loadConfig(); + $this->initContext(); $this->route(); } @@ -406,21 +406,22 @@ private function setReporting() } } - private function loadConfig() + private function initContext() { - self::$config = Config::load('config'); - define('TP_SITE_NAME', self::$config->get('site_name', 'BunnyPHP')); - define('TP_SITE_URL', self::$config->get('site_url', 'localhost')); - define('TP_SITE_REWRITE', self::$config->get('site_rewrite', true)); + $conf = Config::load('config'); + self::$config = $conf; + define('TP_SITE_NAME', $conf->get('site_name', 'BunnyPHP')); + define('TP_SITE_URL', $conf->get('site_url', 'localhost')); + define('TP_SITE_REWRITE', $conf->get('site_rewrite', true)); - if (!defined('TP_NAMESPACE')) define('TP_NAMESPACE', self::$config->get('namespace', '')); + if (!defined('TP_NAMESPACE')) define('TP_NAMESPACE', $conf->get('namespace', '')); - if (self::$config->has('db')) { - define('DB_PREFIX', self::$config->get('db.prefix')); + if ($conf->has('db')) { + define('DB_PREFIX', $conf->get('db.prefix')); } - if (self::$config->has('apps')) { - $this->apps = self::$config->get('apps', []); + if ($conf->has('apps')) { + $this->apps = $conf->get('apps', []); } BunnyPHP::$request = new Request(); } @@ -509,3 +510,4 @@ public static function getDir(string $dir): string return $tmpDir; } } +