TYPO3  7.6
PhpErrorCodeViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Install\ViewHelpers\Format;
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 {
31  protected static $levelNames = array(
32  E_ERROR => 'E_ERROR',
33  E_WARNING => 'E_WARNING',
34  E_PARSE => 'E_PARSE',
35  E_NOTICE => 'E_NOTICE',
36  E_CORE_ERROR => 'E_CORE_ERROR',
37  E_CORE_WARNING => 'E_CORE_WARNING',
38  E_COMPILE_ERROR => 'E_COMPILE_ERROR',
39  E_COMPILE_WARNING => 'E_COMPILE_WARNING',
40  E_USER_ERROR => 'E_USER_ERROR',
41  E_USER_WARNING => 'E_USER_WARNING',
42  E_USER_NOTICE => 'E_USER_NOTICE',
43  E_STRICT => 'E_STRICT',
44  E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
45  E_DEPRECATED => 'E_DEPRECATED',
46  E_USER_DEPRECATED => 'E_USER_DEPRECATED',
47  );
48 
55  public function render($phpErrorCode)
56  {
57  return static::renderStatic(
58  array(
59  'phpErrorCode' => $phpErrorCode,
60  ),
62  $this->renderingContext
63  );
64  }
65 
74  {
75  $phpErrorCode = $arguments['phpErrorCode'];
76  $levels = array();
77  if (($phpErrorCode & E_ALL) == E_ALL) {
78  $levels[] = 'E_ALL';
79  $phpErrorCode &= ~E_ALL;
80  }
81  foreach (self::$levelNames as $level => $name) {
82  if (($phpErrorCode & $level) == $level) {
83  $levels[] = $name;
84  }
85  }
86 
87  $output = '';
88  if (!empty($levels)) {
89  $output = implode(' | ', $levels);
90  }
91 
92  return $output;
93  }
94 }