44 lines
995 B
PHP
44 lines
995 B
PHP
<?php
|
||
/**
|
||
* @package Bicycle
|
||
* @author Egor Isaev
|
||
* @description HTTPException_404.php
|
||
* @copyright (c) 04/06/2026
|
||
*/
|
||
|
||
namespace System\Classes\HTTP\Exception;
|
||
|
||
use System\Classes\Core;
|
||
use System\Classes\HTTP\HTTPException;
|
||
use System\Classes\Response;
|
||
|
||
/**
|
||
* 404 Not Found: рендерит шаблон view/errors/404.html.
|
||
*/
|
||
class HTTPException_404 extends HTTPException
|
||
{
|
||
/** @var int HTTP-код */
|
||
protected int $_code = 404;
|
||
|
||
/**
|
||
* Формирует Response 404 с телом из шаблона ошибки.
|
||
*
|
||
* @return Response
|
||
*/
|
||
public function getResponse(): Response
|
||
{
|
||
http_response_code(404);
|
||
$response = new Response(404);
|
||
$view = Core::findFile('view/errors', '404', 'html');
|
||
|
||
if ($view) {
|
||
ob_start();
|
||
$message = $this->getMessage();
|
||
include $view;
|
||
$response->body(ob_get_clean());
|
||
}
|
||
|
||
return $response;
|
||
}
|
||
}
|