Completed
Push — master ( f81167...15513d )
by Aimeos
02:00
created

Shop   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 0
loc 82
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 30 3
A injectSettings() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://www.gnu.org/copyleft/lgpl.html
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package flow
7
 * @subpackage Base
8
 */
9
10
11
namespace Aimeos\Shop\Base;
12
13
use Neos\Flow\Annotations as Flow;
14
15
16
/**
17
 * Class providing the shop objects
18
 *
19
 * @package flow
20
 * @subpackage Base
21
 * @Flow\Scope("singleton")
22
 */
23
class Shop
24
{
25
	/**
26
	 * @var \Aimeos\Shop\Base\Aimeos
27
	 * @Flow\Inject
28
	 */
29
	protected $aimeos;
30
31
	/**
32
	 * @var \Aimeos\Shop\Base\Context
33
	 * @Flow\Inject
34
	 */
35
	protected $context;
36
37
	/**
38
	 * @var \Aimeos\Shop\Base\View
39
	 * @Flow\Inject
40
	 */
41
	protected $view;
42
43
	/**
44
	 * @var \Neos\Flow\Mvc\Routing\UriBuilder
45
	 * @Flow\Inject
46
	 */
47
	protected $uriBuilder;
48
49
	/**
50
	 * @var array
51
	 */
52
	private $settings;
53
54
55
	/**
56
	 * Returns the body and header sections created by the clients configured for the given page name.
57
	 *
58
	 * @param \Neos\Flow\Mvc\RequestInterface $request Request object
59
	 * @param string $pageName Name of the configured page
60
	 * @return array Associative list with body and header output separated by client name
61
	 */
62
	public function get( \Neos\Flow\Mvc\RequestInterface $request, $pageName )
63
	{
64
		$this->uriBuilder->setRequest( $request );
0 ignored issues
show
Compatibility introduced by
$request of type object<Neos\Flow\Mvc\RequestInterface> is not a sub-type of object<Neos\Flow\Mvc\ActionRequest>. It seems like you assume a concrete implementation of the interface Neos\Flow\Mvc\RequestInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
65
66
		$tmplPaths = $this->aimeos->get()->getCustomPaths( 'client/html/templates' );
67
		$pagesConfig = $this->settings['page'];
68
		$result = array( 'aibody' => array(), 'aiheader' => array() );
69
70
		$context = $this->context->get( $request );
71
		$langid = $context->getLocale()->getLanguageId();
72
		$view = $this->view->create( $context, $this->uriBuilder, $tmplPaths, $request, $langid );
73
		$context->setView( $view );
74
75
		if( isset( $pagesConfig[$pageName] ) )
76
		{
77
			foreach( (array) $pagesConfig[$pageName] as $clientName )
78
			{
79
				$client = \Aimeos\Client\Html::create( $context, $clientName );
80
				$client->setView( clone $view );
81
				$client->process();
82
83
				$varName = str_replace( '/', '_', $clientName );
84
85
				$result['aibody'][$varName] = $client->getBody();
86
				$result['aiheader'][$varName] = $client->getHeader();
87
			}
88
		}
89
90
		return $result;
91
	}
92
93
94
	/**
95
	 * Inject the settings
96
	 *
97
	 * @param array $settings
98
	 * @return void
99
	 */
100
	public function injectSettings( array $settings )
101
	{
102
		$this->settings = $settings;
103
	}
104
}
105