‪TYPO3CMS  10.4
FluidPageErrorHandler.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
25 use TYPO3Fluid\Fluid\View\ViewInterface;
26 
32 {
36  protected ‪$view;
37 
41  protected ‪$statusCode;
42 
48  public function ‪__construct(int ‪$statusCode, array $configuration)
49  {
50  $this->statusCode = ‪$statusCode;
51  $this->view = GeneralUtility::makeInstance(TemplateView::class);
52  if (!empty($configuration['errorFluidTemplatesRootPath'])) {
53  $this->view->setTemplateRootPaths([$configuration['errorFluidTemplatesRootPath']]);
54  }
55  if (!empty($configuration['errorFluidLayoutsRootPath'])) {
56  $this->view->setLayoutRootPaths([$configuration['errorFluidLayoutsRootPath']]);
57  }
58  if (!empty($configuration['errorFluidPartialsRootPath'])) {
59  $this->view->setPartialRootPaths([$configuration['errorFluidPartialsRootPath']]);
60  }
61  $this->view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($configuration['errorFluidTemplate']));
62  }
63 
70  public function ‪handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
71  {
72  $this->view->assignMultiple([
73  'request' => $request,
74  'message' => $message,
75  'reasons' => $reasons
76  ]);
77  return new ‪HtmlResponse($this->view->render(), $this->statusCode);
78  }
79 }
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\handlePageError
‪ResponseInterface handlePageError(ServerRequestInterface $request, string $message, array $reasons=[])
Definition: FluidPageErrorHandler.php:68
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler
Definition: FluidPageErrorHandler.php:32
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\$statusCode
‪int $statusCode
Definition: FluidPageErrorHandler.php:39
‪TYPO3\CMS\Fluid\View\TemplateView
Definition: TemplateView.php:25
‪TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface
Definition: PageErrorHandlerInterface.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Error\PageErrorHandler
Definition: FluidPageErrorHandler.php:18
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\__construct
‪__construct(int $statusCode, array $configuration)
Definition: FluidPageErrorHandler.php:46
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\$view
‪ViewInterface $view
Definition: FluidPageErrorHandler.php:35