‪TYPO3CMS  ‪main
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 
46  public function ‪__construct(int ‪$statusCode, array $configuration)
47  {
48  $this->statusCode = ‪$statusCode;
49  $this->view = GeneralUtility::makeInstance(TemplateView::class);
50  if (!empty($configuration['errorFluidTemplatesRootPath'])) {
51  $this->view->setTemplateRootPaths([$configuration['errorFluidTemplatesRootPath']]);
52  }
53  if (!empty($configuration['errorFluidLayoutsRootPath'])) {
54  $this->view->setLayoutRootPaths([$configuration['errorFluidLayoutsRootPath']]);
55  }
56  if (!empty($configuration['errorFluidPartialsRootPath'])) {
57  $this->view->setPartialRootPaths([$configuration['errorFluidPartialsRootPath']]);
58  }
59  $this->view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($configuration['errorFluidTemplate']));
60  }
61 
62  public function ‪handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface
63  {
64  $this->view->assignMultiple([
65  'request' => $request,
66  'message' => $message,
67  'reasons' => $reasons,
68  ]);
69  return new ‪HtmlResponse($this->view->render(), $this->statusCode);
70  }
71 }
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\handlePageError
‪handlePageError(ServerRequestInterface $request, string $message, array $reasons=[])
Definition: FluidPageErrorHandler.php:60
‪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:22
‪TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface
Definition: PageErrorHandlerInterface.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Error\PageErrorHandler
Definition: FluidPageErrorHandler.php:18
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:28
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\__construct
‪__construct(int $statusCode, array $configuration)
Definition: FluidPageErrorHandler.php:44
‪TYPO3\CMS\Core\Error\PageErrorHandler\FluidPageErrorHandler\$view
‪ViewInterface $view
Definition: FluidPageErrorHandler.php:35