Completed
Push — master ( 19fed6...e690ae )
by
unknown
14:30
created

ArrayBrowserViewHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 35
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderStatic() 0 7 1
A initializeArguments() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace TYPO3\CMS\Backend\ViewHelpers;
5
6
/*
7
 * This file is part of the TYPO3 CMS project.
8
 *
9
 * It is free software; you can redistribute it and/or modify it under
10
 * the terms of the GNU General Public License, either version 2
11
 * of the License, or any later version.
12
 *
13
 * For the full copyright and license information, please read the
14
 * LICENSE.txt file that was distributed with this source code.
15
 *
16
 * The TYPO3 project - inspiring people to share!
17
 */
18
19
use TYPO3\CMS\Backend\View\ArrayBrowser;
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24
25
/**
26
 * Renders a given array as tree
27
 * @internal
28
 */
29
class ArrayBrowserViewHelper extends AbstractViewHelper
30
{
31
    use CompileWithRenderStatic;
32
33
    /**
34
     * As this ViewHelper renders HTML, the output must not be escaped.
35
     *
36
     * @var bool
37
     */
38
    protected $escapeOutput = false;
39
40
    /**
41
     * Initializes the arguments
42
     */
43
    public function initializeArguments()
44
    {
45
        $this->registerArgument('data', 'array', 'Array which should be rendered');
46
    }
47
48
    /**
49
     * Render unordered list for pages
50
     *
51
     * @param array $arguments
52
     * @param \Closure $renderChildrenClosure
53
     * @param RenderingContextInterface $renderingContext
54
     *
55
     * @return string
56
     */
57
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
58
    {
59
        $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
60
        $arrayBrowser->dontLinkVar = true;
61
        $arrayBrowser->expAll = true;
62
63
        return $arrayBrowser->tree($arguments['data'], '');
64
    }
65
}
66