‪TYPO3CMS  10.4
PhpErrorCodeViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
21 
27 class ‪PhpErrorCodeViewHelper extends AbstractViewHelper
28 {
29  use CompileWithRenderStatic;
30 
34  protected static ‪$levelNames = [
35  E_ERROR => 'E_ERROR',
36  E_WARNING => 'E_WARNING',
37  E_PARSE => 'E_PARSE',
38  E_NOTICE => 'E_NOTICE',
39  E_CORE_ERROR => 'E_CORE_ERROR',
40  E_CORE_WARNING => 'E_CORE_WARNING',
41  E_COMPILE_ERROR => 'E_COMPILE_ERROR',
42  E_COMPILE_WARNING => 'E_COMPILE_WARNING',
43  E_USER_ERROR => 'E_USER_ERROR',
44  E_USER_WARNING => 'E_USER_WARNING',
45  E_USER_NOTICE => 'E_USER_NOTICE',
46  E_STRICT => 'E_STRICT',
47  E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
48  E_DEPRECATED => 'E_DEPRECATED',
49  E_USER_DEPRECATED => 'E_USER_DEPRECATED',
50  ];
51 
55  public function ‪initializeArguments()
56  {
57  $this->registerArgument('phpErrorCode', 'int', '', true);
58  }
59 
69  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
70  {
71  $phpErrorCode = (int)$arguments['phpErrorCode'];
72  $levels = [];
73  if (($phpErrorCode & E_ALL) == E_ALL) {
74  $levels[] = 'E_ALL';
75  $phpErrorCode &= ~E_ALL;
76  }
77  foreach (self::$levelNames as $level => $name) {
78  if (($phpErrorCode & $level) == $level) {
79  $levels[] = $name;
80  }
81  }
82 
83  ‪$output = '';
84  if (!empty($levels)) {
85  ‪$output = implode(' | ', $levels);
86  }
87 
88  return ‪$output;
89  }
90 }
‪TYPO3\CMS\Install\ViewHelpers\Format
Definition: NoSpaceViewHelper.php:18
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: PhpErrorCodeViewHelper.php:67
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper
Definition: PhpErrorCodeViewHelper.php:28
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\$levelNames
‪static array $levelNames
Definition: PhpErrorCodeViewHelper.php:32
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper\initializeArguments
‪initializeArguments()
Definition: PhpErrorCodeViewHelper.php:53
‪$output
‪$output
Definition: annotationChecker.php:119