Completed
Push — master ( 95e8d1...b686ff )
by Aimeos
02:04
created

Shop   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A get() 0 13 2
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package symfony
7
 * @subpackage Service
8
 */
9
10
namespace Aimeos\ShopBundle\Service;
11
12
use Symfony\Component\DependencyInjection\Container;
13
14
15
/**
16
 * Service providing the shop object
17
 *
18
 * @package symfony
19
 * @subpackage Service
20
 */
21
class Shop
22
{
23
	private $container;
24
	private $context;
25
	private $objects = [];
26
27
28
	/**
29
	 * Initializes the shop object
30
	 *
31
	 * @param Container $container Container object to access parameters
32
	 */
33
	public function __construct( Container $container )
34
	{
35
		$this->context = $container->get( 'aimeos.context' )->get();
36
37
		$langid = $this->context->getLocale()->getLanguageId();
38
		$tmplPaths = $container->get( 'aimeos' )->get()->getCustomPaths( 'client/html/templates' );
39
40
		$view = $container->get( 'aimeos.view' )->create( $this->context, $tmplPaths, $langid );
41
		$this->context->setView( $view );
42
	}
43
44
45
	/**
46
	 * Returns the HTML client for the given name
47
	 *
48
	 * @param string $name Name of the shop component
49
	 * @return \Aimeos\Client\Html\Iface HTML client
50
	 */
51
	public function get( $name )
52
	{
53
		if( !isset( $this->objects[$name] ) )
54
		{
55
			$client = \Aimeos\Client\Html::create( $this->context, $name );
56
			$client->setView( $this->context->getView() );
57
			$client->process();
58
59
			$this->objects[$name] = $client;
60
		}
61
62
		return $this->objects[$name];
63
	}
64
}
65