ConfigurationViewHelper::initializeArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Filoucrackeur\StorageFrameworkManager\ViewHelpers;
5
6
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
7
8
class ConfigurationViewHelper extends AbstractViewHelper
9
{
10
11
    /**
12
     * @var bool
13
     */
14
    protected $escapeOutput = false;
15
16
    /**
17
     * @var bool
18
     */
19
    protected $escapeChildren = false;
20
21
    /**
22
     * Initialize arguments.
23
     */
24
    public function initializeArguments()
25
    {
26
        parent::initializeArguments();
27
        $this->registerArgument('type', 'string', 'Backend type session or cache', true);
28
        $this->registerArgument('identifier', 'string', 'Cache identifier', false, null);
29
    }
30
31
    /**
32
     * @return array|null
33
     */
34
    public function render(): ?array
35
    {
36
        if ($this->arguments['type'] === 'cache') {
37
38
            if (isset($this->arguments['identifier']) && '' !== $this->arguments['identifier']) {
39
                return $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$this->arguments['identifier']];
40
            }
41
42
            return $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
43
        }
44
45
        if ($this->arguments['type'] === 'session') {
46
47
            if (isset($this->arguments['identifier']) && '' !== $this->arguments['identifier']) {
48
                return $GLOBALS['TYPO3_CONF_VARS']['SYS']['session'][$this->arguments['identifier']];
49
            }
50
51
            return $GLOBALS['TYPO3_CONF_VARS']['SYS']['session'];
52
        }
53
54
        return null;
55
    }
56
}
57