TYPO3 CMS  TYPO3_8-7
PhpErrorCodeViewHelper.php
Go to the documentation of this file.
1 <?php
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 
20 
27 {
29 
33  protected static $levelNames = [
34  E_ERROR => 'E_ERROR',
35  E_WARNING => 'E_WARNING',
36  E_PARSE => 'E_PARSE',
37  E_NOTICE => 'E_NOTICE',
38  E_CORE_ERROR => 'E_CORE_ERROR',
39  E_CORE_WARNING => 'E_CORE_WARNING',
40  E_COMPILE_ERROR => 'E_COMPILE_ERROR',
41  E_COMPILE_WARNING => 'E_COMPILE_WARNING',
42  E_USER_ERROR => 'E_USER_ERROR',
43  E_USER_WARNING => 'E_USER_WARNING',
44  E_USER_NOTICE => 'E_USER_NOTICE',
45  E_STRICT => 'E_STRICT',
46  E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
47  E_DEPRECATED => 'E_DEPRECATED',
48  E_USER_DEPRECATED => 'E_USER_DEPRECATED',
49  ];
50 
54  public function initializeArguments()
55  {
56  parent::initializeArguments();
57  $this->registerArgument('phpErrorCode', 'int', '', true);
58  }
59 
69  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
70  {
71  $phpErrorCode = $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 }
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)