‪TYPO3CMS  9.5
ErrorPageController.php
Go to the documentation of this file.
1 <?php
2 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 
22 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContext;
23 use TYPO3Fluid\Fluid\View\TemplatePaths;
24 use TYPO3Fluid\Fluid\View\TemplateView;
25 
31 {
36  protected ‪$view;
37 
43 
47  public function ‪__construct()
48  {
49  $this->view = GeneralUtility::makeInstance(TemplateView::class);
50  $context = new RenderingContext($this->view);
51  $context->setControllerName('ErrorPage');
52  $context->setTemplatePaths(new TemplatePaths([
53  'templateRootPaths' => [
54  ‪Environment::getFrameworkBasePath() . '/core/Resources/Private/Templates/ErrorPage/'
55  ]
56  ]));
57  $this->view->setRenderingContext($context);
58  }
59 
69  public function ‪errorAction(
70  string $title,
71  string $message,
73  int $errorCode = 0
74  ): string {
75  $this->severity = ‪$severity;
76  $classes = [
77  ‪AbstractMessage::NOTICE => 'notice',
78  ‪AbstractMessage::INFO => 'information',
79  ‪AbstractMessage::OK => 'ok',
80  ‪AbstractMessage::WARNING => 'warning',
81  ‪AbstractMessage::ERROR => 'error'
82  ];
83  $this->view->assign('severityCssClass', $classes[$this->severity]);
84  $this->view->assign('severity', $this->severity);
85  $this->view->assign('message', $message);
86  $this->view->assign('title', $title);
87  $this->view->assign('errorCodeUrlPrefix', TYPO3_URL_EXCEPTION);
88  $this->view->assign('errorCode', $errorCode);
89  $this->view->assign('logo', ‪PathUtility::getAbsoluteWebPath(‪Environment::getFrameworkBasePath() . '/backend/Resources/Public/Images/typo3_orange.svg'));
90  $this->view->assign('cssFile', ‪PathUtility::getAbsoluteWebPath(‪Environment::getFrameworkBasePath() . '/core/Resources/Public/Css/errorpage.css'));
91  $this->view->assign('copyrightYear', TYPO3_copyright_year);
92  return $this->view->render('Error');
93  }
94 }
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:23
‪TYPO3\CMS\Core\Messaging\AbstractMessage
Definition: AbstractMessage.php:24
‪TYPO3\CMS\Core\Controller\ErrorPageController
Definition: ErrorPageController.php:31
‪TYPO3\CMS\Core\Controller\ErrorPageController\$severity
‪int $severity
Definition: ErrorPageController.php:40
‪TYPO3\CMS\Core\Controller\ErrorPageController\$view
‪TemplateView $view
Definition: ErrorPageController.php:35
‪TYPO3\CMS\Core\Controller
Definition: ErrorPageController.php:3
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:234
‪TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING
‪const WARNING
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Controller\ErrorPageController\__construct
‪__construct()
Definition: ErrorPageController.php:45
‪TYPO3\CMS\Core\Messaging\AbstractMessage\OK
‪const OK
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:26
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Controller\ErrorPageController\errorAction
‪string errorAction(string $title, string $message, int $severity=AbstractMessage::ERROR, int $errorCode=0)
Definition: ErrorPageController.php:67
‪TYPO3\CMS\Core\Messaging\AbstractMessage\NOTICE
‪const NOTICE
Definition: AbstractMessage.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:42
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29