‪TYPO3CMS  10.4
ErrorPageController.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 
25 use TYPO3Fluid\Fluid\View\TemplateView;
26 
32 {
37  protected ‪$view;
38 
44 
48  public function ‪__construct()
49  {
50  $this->view = GeneralUtility::makeInstance(TemplateView::class);
51  $this->view->getRenderingContext()
52  ->getTemplatePaths()
53  ->setTemplatePathAndFilename(
54  ‪Environment::getFrameworkBasePath() . '/core/Resources/Private/Templates/ErrorPage/Error.html'
55  );
56  }
57 
67  public function ‪errorAction(
68  string $title,
69  string $message,
71  int $errorCode = 0
72  ): string {
73  $this->severity = ‪$severity;
74  $classes = [
75  ‪AbstractMessage::NOTICE => 'notice',
76  ‪AbstractMessage::INFO => 'information',
77  ‪AbstractMessage::OK => 'ok',
78  ‪AbstractMessage::WARNING => 'warning',
79  ‪AbstractMessage::ERROR => 'error'
80  ];
81  $this->view->assign('severityCssClass', $classes[$this->severity]);
82  $this->view->assign('severity', $this->severity);
83  $this->view->assign('message', $message);
84  $this->view->assign('title', $title);
85  $this->view->assign('errorCodeUrlPrefix', ‪Typo3Information::URL_EXCEPTION);
86  $this->view->assign('errorCode', $errorCode);
87  $this->view->assign('logo', ‪PathUtility::getAbsoluteWebPath(‪Environment::getFrameworkBasePath() . '/backend/Resources/Public/Images/typo3_orange.svg'));
88  $this->view->assign('cssFile', ‪PathUtility::getAbsoluteWebPath(‪Environment::getFrameworkBasePath() . '/core/Resources/Public/Css/errorpage.css'));
89  $this->view->assign('copyrightYear', GeneralUtility::makeInstance(Typo3Information::class)->getCopyrightYear());
90  return $this->view->render();
91  }
92 }
‪TYPO3\CMS\Core\Utility\PathUtility
Definition: PathUtility.php:24
‪TYPO3\CMS\Core\Messaging\AbstractMessage
Definition: AbstractMessage.php:26
‪TYPO3\CMS\Core\Information\Typo3Information
Definition: Typo3Information.php:26
‪TYPO3\CMS\Core\Controller\ErrorPageController
Definition: ErrorPageController.php:32
‪TYPO3\CMS\Core\Controller\ErrorPageController\$severity
‪int $severity
Definition: ErrorPageController.php:41
‪TYPO3\CMS\Core\Controller\ErrorPageController\$view
‪TemplateView $view
Definition: ErrorPageController.php:36
‪TYPO3\CMS\Core\Information\Typo3Information\URL_EXCEPTION
‪const URL_EXCEPTION
Definition: Typo3Information.php:29
‪TYPO3\CMS\Core\Controller
Definition: ErrorPageController.php:18
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:261
‪TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING
‪const WARNING
Definition: AbstractMessage.php:30
‪TYPO3\CMS\Core\Controller\ErrorPageController\__construct
‪__construct()
Definition: ErrorPageController.php:46
‪TYPO3\CMS\Core\Messaging\AbstractMessage\OK
‪const OK
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Controller\ErrorPageController\errorAction
‪string errorAction(string $title, string $message, int $severity=AbstractMessage::ERROR, int $errorCode=0)
Definition: ErrorPageController.php:65
‪TYPO3\CMS\Core\Messaging\AbstractMessage\NOTICE
‪const NOTICE
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\PathUtility\getAbsoluteWebPath
‪static string getAbsoluteWebPath($targetPath)
Definition: PathUtility.php:43
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31