[TASK] Merge test splitter scripts to core
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Classes / ViewHelpers / Format / GroupListViewHelper.php
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
16 namespace TYPO3\CMS\IndexedSearch\ViewHelpers\Format;
17
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
21
22 /**
23 * Group list viewhelper
24 * @internal
25 */
26 class GroupListViewHelper extends AbstractViewHelper
27 {
28 use CompileWithRenderStatic;
29
30 /**
31 * Initialize arguments
32 */
33 public function initializeArguments()
34 {
35 $this->registerArgument('groups', 'array', '', false, []);
36 }
37
38 /**
39 * Render the given group information as string
40 *
41 * @param array $arguments
42 * @param \Closure $renderChildrenClosure
43 * @param RenderingContextInterface $renderingContext
44 *
45 * @return string
46 */
47 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
48 {
49 $groups = $arguments['groups'];
50
51 $str = [];
52 foreach ($groups as $row) {
53 $str[] = $row['gr_list'] === '0,-1' ? 'NL' : $row['gr_list'];
54 }
55 arsort($str);
56 return implode('|', $str);
57 }
58 }