ConfigViewHelper::render()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 9
nc 4
nop 0
dl 0
loc 17
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license GPLv3, http://www.gnu.org/copyleft/gpl.html
5
 * @copyright Aimeos (aimeos.org), 2017
6
 * @package TYPO3
7
 */
8
9
10
namespace Aimeos\Aimeos\ViewHelper;
11
12
13
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
14
15
16
class ConfigViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
17
{
18
    protected $escapeOutput = false;
19
20
21
    public function initializeArguments()
22
    {
23
        $this->registerArgument('key', 'string', 'Configuration key, e.g. client/html/catalog/lists/basket-add');
24
        $this->registerArgument('default', 'mixed', 'Value if no configuration for the given key was found', false);
25
    }
26
27
28
    public function render()
29
    {
30
        $iface = '\Aimeos\Base\View\Iface';
31
        $view = $this->templateVariableContainer->get('_aimeos_view');
32
33
        if (!is_object($view) || !($view instanceof $iface)) {
34
            throw new Exception('Aimeos view object is missing');
35
        }
36
37
        if (!isset($this->arguments['key'])) {
38
            throw new Exception('Attribute "key" missing for Aimeos config view helper');
39
        }
40
41
        $key = $this->arguments['key'];
42
        $default = (isset($this->arguments['default']) ? $this->arguments['default'] : null);
43
44
        return $view->config($key, $default);
45
    }
46
}
47