From c929c0c090e78a39fb219850795f16687409fadc Mon Sep 17 00:00:00 2001 From: mychidarko Date: Tue, 13 Aug 2024 00:30:51 +0000 Subject: [PATCH] feat: increase base performance --- src/App.php | 9 +++++---- src/View.php | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.php b/src/App.php index e35a733..59cb536 100755 --- a/src/App.php +++ b/src/App.php @@ -41,8 +41,8 @@ public function __construct(array $userSettings = []) $this->container = new Helpers\Container(); $this->loadConfig($userSettings); - if (!empty($this->config('scripts'))) { - foreach ($this->config('scripts') as $script) { + if (!empty(Config::get('scripts'))) { + foreach (Config::get('scripts') as $script) { \call_user_func($script, $this, Config::get()); } @@ -72,7 +72,7 @@ protected function setupErrorHandler() */ public function setErrorHandler($handler) { - if (Anchor::toBool($this->config('debug')) === false) { + if (Anchor::toBool(Config::get('debug')) === false) { if ($this->errorHandler instanceof Exception\Run) { $this->errorHandler->unregister(); } @@ -124,9 +124,10 @@ private function setupDefaultContainer() return new Http\Headers(); }); - Config::set('mode', _env('APP_ENV', $this->config('mode'))); Config::set('app.instance', $this); Config::set('app.container', $this->container); + + $this->config('mode', _env('APP_ENV', Config::get('mode'))); } public function __get($name) diff --git a/src/View.php b/src/View.php index a80beda..5af1540 100644 --- a/src/View.php +++ b/src/View.php @@ -25,7 +25,9 @@ class View public static function attach($className, $name = null) { $class = new $className(); + static::$engines[$name ?? static::getDiIndex($class)] = $class; + Config::set('views.engine', $name ?? static::getDiIndex($class)); }