From 67e527bbbc959e2bf549cf8b0b2fff30c1871f3b Mon Sep 17 00:00:00 2001 From: bim-g Date: Sat, 29 Jul 2023 21:48:49 +0200 Subject: [PATCH] [ENH] setup application layout to point into views folder. --- index.php | 2 +- src/Core/Application.php | 2 +- src/Core/View.php | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index ba08cd0..be4b260 100644 --- a/index.php +++ b/index.php @@ -24,6 +24,6 @@ $app = new Application($ROOT_DIR, $configuration); -require_once Application::$ROOT_DIR . '/router/route.php'; +require_once $app::$ROOT_DIR . '/router/route.php'; $app->run(); diff --git a/src/Core/Application.php b/src/Core/Application.php index 0691b80..4d3184b 100644 --- a/src/Core/Application.php +++ b/src/Core/Application.php @@ -115,7 +115,7 @@ public static function dumper($ex) */ public static function setLayout(string $layout) { - self::$LAYOUT = $layout; + self::$LAYOUT = self::$ROOT_DIR.'/views/'.$layout; } /** diff --git a/src/Core/View.php b/src/Core/View.php index b52e898..b4a9282 100644 --- a/src/Core/View.php +++ b/src/Core/View.php @@ -157,6 +157,9 @@ protected function renderLayout(string $view) */ private function buildAssetHead($html) { + if(!$html){ + throwException('Unable to render empty data'); + } $dom = new \DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML( @@ -207,6 +210,10 @@ public function assign(string $variable, $value) */ public function setLayout(string $template) { - $this->layout = $template; + $this->layout = Application::$ROOT_DIR . '/views/' . $template; + } + + public function setLayoutContent(string $layout_name){ + $this->layout_content = $layout_name; } } \ No newline at end of file