misuzu/utility.php

20 lines
576 B
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
2023-07-10 20:12:20 +00:00
// render_error and render_info need to be nuked from orbit
2022-09-13 13:14:49 +00:00
function render_error(int $code, string $template = 'errors.%d'): string {
return render_info(null, $code, $template);
}
function render_info(?string $message, int $httpCode, string $template = 'errors.%d'): string {
http_response_code($httpCode);
\Misuzu\Template::set('http_code', $httpCode);
if(!empty($message))
\Misuzu\Template::set('message', $message);
$template = sprintf($template, $httpCode);
return \Misuzu\Template::renderRaw(sprintf($template, $httpCode));
}