From 9a2f35af2bd08c4eabeb6f891bf4992d40a51923 Mon Sep 17 00:00:00 2001 From: bim-g Date: Sun, 22 Sep 2024 13:53:17 +0200 Subject: [PATCH] [UPD] refactoring to accesse layout param via getter method --- router/route.php | 2 +- src/Core/Application.php | 12 ++++++------ src/Core/Views/View.php | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/router/route.php b/router/route.php index 396b5c6..fc00b35 100644 --- a/router/route.php +++ b/router/route.php @@ -18,4 +18,4 @@ $router->post('/changelang', [indexController::class, 'changeLang']) ->middleware([exampleValidation::class, 'changeLang']); -include \Wepesi\Core\Application::$ROOT_DIR . './router/api.php'; \ No newline at end of file +include \Wepesi\Core\Application::getRootDir() . './router/api.php'; \ No newline at end of file diff --git a/src/Core/Application.php b/src/Core/Application.php index 1f8907b..41b2bb7 100644 --- a/src/Core/Application.php +++ b/src/Core/Application.php @@ -36,7 +36,7 @@ class Application /** * @var string */ - public static string $LAYOUT_CONTENT; + public static string $layout_content_param; /** * @var string */ @@ -63,7 +63,7 @@ public function __construct(string $path, AppConfiguration $config) self::$APP_DOMAIN = serverDomain()->domain; self::$APP_LANG = self::$config_params['lang'] ?? 'fr'; self::$APP_TEMPLATE = self::$config_params['app_template'] ?? ''; - self::$LAYOUT_CONTENT = 'layout_content'; + self::$layout_content_param = 'layout_content'; self::$layout = ''; self::$VIEW_FOLDER = ''; $this->router = new Router(); @@ -105,9 +105,9 @@ public static function setLayout(string $layout) * @param string $layout_name * @return void */ - public static function setLayoutContent(string $layout_name) + public static function setLayoutcontentparam(string $layout_name) { - self::$LAYOUT_CONTENT = $layout_name; + self::$layout_content_param = $layout_name; } /** @@ -130,9 +130,9 @@ public static function getLayout(): ?string /** * @return string */ - public static function getLayoutContent() + public static function getLayoutContentParam(): string { - return self::$LAYOUT_CONTENT ; + return self::$layout_content_param ; } /** diff --git a/src/Core/Views/View.php b/src/Core/Views/View.php index 0953356..4819273 100644 --- a/src/Core/Views/View.php +++ b/src/Core/Views/View.php @@ -144,7 +144,7 @@ private function renderNotDefined(string $file_name): void protected function renderLayout(string $view) { if ($this->layout_content === '') { - $this->layout_content = Application::getLayoutContent(); + $this->layout_content = Application::getLayoutContentParam(); } if ($this->layout && is_file($this->layout)) { $layout_data = $this->data; @@ -228,5 +228,4 @@ private function generateJSLink(string $path): string private function generateStyleLink(string $path): string { return ''; } - }