[TASK] Streamline phpdoc annotations in EXT:extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / View / NotFoundView.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\View;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * The not found view - a special case.
19 * @internal only to be used within Extbase, not part of TYPO3 Core API.
20 */
21 class NotFoundView extends \TYPO3\CMS\Extbase\Mvc\View\AbstractView
22 {
23 /**
24 * @var array
25 */
26 protected $variablesMarker = ['errorMessage' => 'ERROR_MESSAGE'];
27
28 /**
29 * Renders the not found view
30 *
31 * @return string The rendered view
32 * @throws \TYPO3\CMS\Extbase\Mvc\Exception if no request has been set
33 */
34 public function render()
35 {
36 if (!is_object($this->controllerContext->getRequest())) {
37 throw new \TYPO3\CMS\Extbase\Mvc\Exception('Can\'t render view without request object.', 1192450280);
38 }
39 $template = file_get_contents($this->getTemplatePathAndFilename());
40 if ($this->controllerContext->getRequest() instanceof \TYPO3\CMS\Extbase\Mvc\Web\Request) {
41 $template = str_replace('###BASEURI###', \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), $template);
42 }
43 foreach ($this->variablesMarker as $variableName => $marker) {
44 $variableValue = $this->variables[$variableName] ?? '';
45 $template = str_replace('###' . $marker . '###', $variableValue, $template);
46 }
47 return $template;
48 }
49
50 /**
51 * Retrieves path and filename of the not-found-template
52 *
53 * @return string path and filename of the not-found-template
54 */
55 protected function getTemplatePathAndFilename()
56 {
57 return \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extbase') . 'Resources/Private/MVC/NotFoundView_Template.html';
58 }
59
60 /**
61 * A magic call method.
62 *
63 * Because this not found view is used as a Special Case in situations when no matching
64 * view is available, it must be able to handle method calls which originally were
65 * directed to another type of view. This magic method should prevent PHP from issuing
66 * a fatal error.
67 *
68 * @param string $methodName
69 * @param array $arguments
70 */
71 public function __call($methodName, array $arguments)
72 {
73 }
74 }