From bf8e5b5f4dc09ee17ed563f6414d99a2b4f9765f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sat, 27 Jun 2020 00:23:17 +0200 Subject: [PATCH] MAPG-89 adaptations in HtmlContent and index.php --- public/index.php | 3 ++- src/Response/HtmlContent.php | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/public/index.php b/public/index.php index 24595aa..0a7084d 100644 --- a/public/index.php +++ b/public/index.php @@ -47,5 +47,6 @@ if ($match !== null) { } } +$content = new MapGuesser\Response\HtmlContent('error/404'); header('Content-Type: text/html; charset=UTF-8', true, 404); -require ROOT . '/views/error/404.php'; +echo $content->render(); diff --git a/src/Response/HtmlContent.php b/src/Response/HtmlContent.php index 0ad813a..8664cf8 100644 --- a/src/Response/HtmlContent.php +++ b/src/Response/HtmlContent.php @@ -1,21 +1,28 @@ template = $template; + $this->view = $view; $this->data = &$data; } public function &render(): string { + if (!empty($_ENV['DEV'])) { + $generator = new Linker($this->view); + $generator->generate(); + } + extract($this->data); ob_start(); - require ROOT . '/views/' . $this->template . '.php'; + require ROOT . '/cache/views/' . $this->view . '.php'; $content = ob_get_contents(); ob_end_clean();