2022-03-15 21:38:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Jump\Pages;
|
|
|
|
|
|
|
|
|
|
class ErrorPage {
|
|
|
|
|
|
|
|
|
|
private string $content;
|
|
|
|
|
|
|
|
|
|
public function __construct(private \Jump\Cache $cache, private \Jump\Config $config, private int $httpcode, public string $message) {
|
|
|
|
|
$this->mustache = new \Mustache_Engine([
|
|
|
|
|
'loader' => new \Mustache_Loader_FilesystemLoader($this->config->get('templatedir'))
|
|
|
|
|
]);
|
|
|
|
|
$this->content = $cache->load(cachename: 'templates/errorpage', key: $httpcode.md5($message), callback: function() use ($httpcode, $message) {
|
|
|
|
|
$template = $this->mustache->loadTemplate('errorpage');
|
|
|
|
|
return $template->render([
|
|
|
|
|
'code' => $httpcode,
|
|
|
|
|
'message' => $message
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function init() {
|
|
|
|
|
http_response_code($this->httpcode);
|
|
|
|
|
die($this->content);
|
|
|
|
|
}
|
2022-03-17 10:34:25 +00:00
|
|
|
|
|
|
|
|
}
|