3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller\Visitor
;
8 use Slim\Http\Response
;
11 * Controller used to render the 404 error page.
13 class ErrorNotFoundController
extends ShaarliVisitorController
15 public function __invoke(Request
$request, Response
$response): Response
17 // Request from the API
18 if (false !== strpos($request->getRequestTarget(), '/api/v1')) {
19 return $response->withStatus(404);
22 // This is required because the middleware is ignored if the route is not found.
23 $this->container
->basePath
= rtrim($request->getUri()->getBasePath(), '/');
25 $this->assignView('error_message', t('Requested page could not be found.'));
27 return $response->withStatus(404)->write($this->render('404'));