2020-05-31 20:41:16 +02:00
|
|
|
<?php namespace MapGuesser\Response;
|
2020-05-19 03:13:55 +02:00
|
|
|
|
2020-05-31 20:41:16 +02:00
|
|
|
class HtmlContent extends ContentBase
|
2020-05-19 03:13:55 +02:00
|
|
|
{
|
|
|
|
private string $template;
|
|
|
|
|
|
|
|
public function __construct(string $template, array &$data = [])
|
|
|
|
{
|
|
|
|
$this->template = $template;
|
|
|
|
$this->data = &$data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function &render(): string
|
|
|
|
{
|
|
|
|
extract($this->data);
|
|
|
|
|
|
|
|
ob_start();
|
|
|
|
require ROOT . '/views/' . $this->template . '.php';
|
|
|
|
$content = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getContentType(): string
|
|
|
|
{
|
|
|
|
return 'text/html';
|
|
|
|
}
|
|
|
|
}
|