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