AbstractController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 15
c 3
b 0
f 0
dl 0
loc 58
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A getOutput() 0 14 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://www.gnu.org/copyleft/lgpl.html
5
 * @copyright Aimeos (aimeos.org), 2014-2016
6
 * @package flow
7
 * @subpackage Controller
8
 */
9
10
11
namespace Aimeos\Shop\Controller;
12
13
use Neos\Flow\Annotations as Flow;
14
15
16
/**
17
 * Abstract class with common functionality for all controllers.
18
 * @package flow
19
 * @subpackage Controller
20
 */
21
abstract class AbstractController extends \Neos\Flow\Mvc\Controller\ActionController
22
{
23
	/**
24
	 * @var \Aimeos\Shop\Base\Aimeos
25
	 * @Flow\Inject
26
	 */
27
	protected $aimeos;
28
29
	/**
30
	 * @var \Aimeos\Shop\Base\Context
31
	 * @Flow\Inject
32
	 */
33
	protected $context;
34
35
	/**
36
	 * @var \Aimeos\Shop\Base\Shop
37
	 * @Flow\Inject
38
	 */
39
	protected $shop;
40
41
	/**
42
	 * @var \Aimeos\Shop\Base\View
43
	 * @Flow\Inject
44
	 */
45
	protected $viewContainer;
46
47
48
	/**
49
	 * Returns the output of the client and adds the header.
50
	 *
51
	 * @param string $clientName Html client name
52
	 * @return string HTML code for inserting into the HTML body
53
	 */
54
	protected function getOutput( $clientName )
55
	{
56
		$tmplPaths = $this->aimeos->get()->getCustomPaths( 'client/html/templates' );
57
		$context = $this->context->get( $this->request );
58
		$langid = $context->getLocale()->getLanguageId();
59
		$view = $this->viewContainer->create( $context, $this->uriBuilder, $tmplPaths, $this->request, $langid );
60
61
		$client = \Aimeos\Client\Html::create( $context, $clientName );
62
		$client->setView( $view );
63
		$client->process();
64
65
		$this->view->assign( 'aimeos_component_header', (string) $client->getHeader() );
66
67
		return $client->getBody();
68
	}
69
70
71
	/**
72
	 * Returns the body and header output for the given page name
73
	 *
74
	 * @param string $name Page name as defined in the Settings.yaml file
75
	 */
76
	protected function get( $name )
77
	{
78
		return $this->shop->get( $this->request, $name );
79
	}
80
}
81