‪TYPO3CMS  ‪main
FlagValueViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24 
28 final class ‪FlagValueViewHelper extends AbstractViewHelper
29 {
30  use CompileWithRenderStatic;
31 
32  protected ‪$escapeOutput = false;
33 
34  public function ‪initializeArguments(): void
35  {
36  $this->registerArgument('flags', 'int', '', true);
37  }
38 
42  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
43  {
44  $flags = (int)($arguments['flags'] ?? 0);
45  $languageService = ‪self::getLanguageService();
46  $content = [];
47  if ($flags & 128) {
48  $content[] = '<span class="badge badge-secondary">'
49  . htmlspecialchars($languageService->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xlf:administration.flag.128'))
50  . '</span>';
51  }
52  if ($flags & 64) {
53  $content[] = '<span class="badge badge-secondary">'
54  . htmlspecialchars($languageService->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xlf:administration.flag.64'))
55  . '</span>';
56  }
57  if ($flags & 32) {
58  $content[] = '<span class="badge badge-secondary">'
59  . htmlspecialchars($languageService->sL('LLL:EXT:indexed_search/Resources/Private/Language/locallang.xlf:administration.flag.32'))
60  . '</span>';
61  }
62  return implode(' ', $content);
63  }
64 
65  protected static function ‪getLanguageService(): ‪LanguageService
66  {
67  return ‪$GLOBALS['LANG'];
68  }
69 }
‪TYPO3\CMS\IndexedSearch\ViewHelpers\Format\FlagValueViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: FlagValueViewHelper.php:41
‪TYPO3\CMS\IndexedSearch\ViewHelpers\Format\FlagValueViewHelper
Definition: FlagValueViewHelper.php:29
‪TYPO3\CMS\IndexedSearch\ViewHelpers\Format\FlagValueViewHelper\getLanguageService
‪static getLanguageService()
Definition: FlagValueViewHelper.php:64
‪TYPO3\CMS\IndexedSearch\ViewHelpers\Format\FlagValueViewHelper\$escapeOutput
‪$escapeOutput
Definition: FlagValueViewHelper.php:31
‪TYPO3\CMS\IndexedSearch\ViewHelpers\Format
Definition: DateTimeViewHelper.php:18
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\IndexedSearch\ViewHelpers\Format\FlagValueViewHelper\initializeArguments
‪initializeArguments()
Definition: FlagValueViewHelper.php:33