Completed
Push — master ( 732333...251e18 )
by Aimeos
01:56
created

ConfigViewHelper::initializeArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license GPLv3, http://www.gnu.org/copyleft/gpl.html
5
 * @copyright Aimeos (aimeos.org), 2017
6
 * @package Flow
7
 */
8
9
10
namespace Aimeos\Shop\ViewHelper;
11
12
13
use TYPO3\Fluid\Core\ViewHelper\Exception;
14
15
16
class ConfigViewHelper extends TYPO3\Fluid\Core\AbstractViewHelper
17
{
18
	protected $escapeChildren = 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\MW\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 translate 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
}