Skip to content

Commit

Permalink
rename to initContext
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLuLyf committed Oct 1, 2022
1 parent 8fd774a commit 8c81cc7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions BunnyPHP/BunnyPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -509,3 +510,4 @@ public static function getDir(string $dir): string
return $tmpDir;
}
}

0 comments on commit 8c81cc7

Please sign in to comment.