ConfigurationViewHelper   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 49
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initializeArguments() 0 6 1
B render() 0 22 7
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