TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ErrorIconViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Belog\ViewHelpers;
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 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 
28 {
34  protected $escapeOutput = false;
35 
39  public function initializeArguments()
40  {
41  parent::initializeArguments();
42  $this->registerArgument('errorNumber', 'int', 'The error number (0 ... 3)', false, 0);
43  }
44 
51  public function render()
52  {
53  return static::renderStatic(
54  $this->arguments,
55  $this->buildRenderChildrenClosure(),
56  $this->renderingContext
57  );
58  }
59 
67  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
68  {
69  $errorSymbols = [
70  '0' => '',
71  '1' => 'status-dialog-warning',
72  '2' => 'status-dialog-error',
73  '3' => 'status-dialog-error'
74  ];
75  if ($errorSymbols[$arguments['errorNumber']]) {
76  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
77  return $iconFactory->getIcon($errorSymbols[$arguments['errorNumber']], Icon::SIZE_SMALL)->render();
78  } else {
79  return '';
80  }
81  }
82 }
static renderStatic(array $arguments,\Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
static makeInstance($className,...$constructorArguments)