BlockViewHelper::initializeArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 Neos\FluidAdaptor\Core\ViewHelper\Exception;
14
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;
15
16
17
/**
18
 * Aimeos block view helper
19
 *
20
 * @package Flow
21
 * @subpackage ViewHelper
22
 */
23
class BlockViewHelper extends AbstractViewHelper
24
{
25
	protected $escapeChildren = false;
26
27
28
	/**
29
	 * Registers the known arguments
30
	 */
31
	public function initializeArguments()
32
	{
33
		$this->registerArgument( 'name', 'string', 'Name of the content block' );
34
	}
35
36
37
	/**
38
	 * Adds the rendered Fluid section to the Aimeos block view helper
39
	 */
40
	public function render()
41
	{
42
		$iface = '\Aimeos\MW\View\Iface';
43
		$view = $this->templateVariableContainer->get( '_aimeos_view' );
44
45
		if( !is_object( $view ) || !( $view instanceof $iface ) ) {
46
			throw new Exception( 'Aimeos view object is missing' );
47
		}
48
49
		if( !isset( $this->arguments['name'] ) ) {
50
			throw new Exception( 'Attribute "name" missing for Aimeos translate view helper' );
51
		}
52
53
		$view->block()->set( $this->arguments['name'], $this->renderChildren() );
54
	}
55
}