Shop   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A get() 0 12 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;
0 ignored issues
show
introduced by
The private property $container is not used, and could be removed.
Loading history...
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->locale()->getLanguageId();
38
		$tmplPaths = $container->get( 'aimeos' )->get()->getTemplatePaths( '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->view() );
57
			$client->init();
58
59
			$this->objects[$name] = $client;
60
		}
61
62
		return $this->objects[$name];
63
	}
64
}
65