MAPG-89 adaptations in HtmlContent and index.php
This commit is contained in:
parent
c8a49396c2
commit
bf8e5b5f4d
@ -47,5 +47,6 @@ if ($match !== null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$content = new MapGuesser\Response\HtmlContent('error/404');
|
||||||
header('Content-Type: text/html; charset=UTF-8', true, 404);
|
header('Content-Type: text/html; charset=UTF-8', true, 404);
|
||||||
require ROOT . '/views/error/404.php';
|
echo $content->render();
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
<?php namespace MapGuesser\Response;
|
<?php namespace MapGuesser\Response;
|
||||||
|
|
||||||
|
use MapGuesser\View\Linker;
|
||||||
|
|
||||||
class HtmlContent extends ContentBase
|
class HtmlContent extends ContentBase
|
||||||
{
|
{
|
||||||
private string $template;
|
private string $view;
|
||||||
|
|
||||||
public function __construct(string $template, array &$data = [])
|
public function __construct(string $view, array &$data = [])
|
||||||
{
|
{
|
||||||
$this->template = $template;
|
$this->view = $view;
|
||||||
$this->data = &$data;
|
$this->data = &$data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function &render(): string
|
public function &render(): string
|
||||||
{
|
{
|
||||||
|
if (!empty($_ENV['DEV'])) {
|
||||||
|
$generator = new Linker($this->view);
|
||||||
|
$generator->generate();
|
||||||
|
}
|
||||||
|
|
||||||
extract($this->data);
|
extract($this->data);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
require ROOT . '/views/' . $this->template . '.php';
|
require ROOT . '/cache/views/' . $this->view . '.php';
|
||||||
$content = ob_get_contents();
|
$content = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user