MAPG-89 adaptations in HtmlContent and index.php

This commit is contained in:
Bence Pőcze 2020-06-27 00:23:17 +02:00
parent c8a49396c2
commit bf8e5b5f4d
Signed by: bence
GPG Key ID: AA52B11A3269D1C1
2 changed files with 13 additions and 5 deletions

View File

@ -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();

View File

@ -1,21 +1,28 @@
<?php namespace MapGuesser\Response;
use MapGuesser\View\Linker;
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;
}
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();