1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 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 configuration objects |
17
|
|
|
* |
18
|
|
|
* @package symfony |
19
|
|
|
* @subpackage Service |
20
|
|
|
*/ |
21
|
|
|
class Config |
22
|
|
|
{ |
23
|
|
|
private $container; |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Initializes the object |
28
|
|
|
* |
29
|
|
|
* @param Container $container Container object to access parameters |
30
|
|
|
*/ |
31
|
|
|
public function __construct( Container $container ) |
32
|
|
|
{ |
33
|
|
|
$this->container = $container; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns the config object |
39
|
|
|
* |
40
|
|
|
* @param string $type Configuration type ("frontend" or "backend") |
41
|
|
|
* @return \Aimeos\Base\Config\Iface Config object |
42
|
|
|
*/ |
43
|
|
|
public function get( $type = 'frontend' ) |
44
|
|
|
{ |
45
|
|
|
$configPaths = $this->container->get( 'aimeos' )->get()->getConfigPaths(); |
46
|
|
|
|
47
|
|
|
$conf = new \Aimeos\Base\Config\PHPArray( [], $configPaths ); |
48
|
|
|
|
49
|
|
|
$apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' ); |
50
|
|
|
$prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' ); |
51
|
|
|
|
52
|
|
|
if( function_exists( 'apcu_store' ) === true && $apc === true ) { |
53
|
|
|
$conf = new \Aimeos\Base\Config\Decorator\APC( $conf, $prefix ); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$local = array( |
57
|
|
|
'admin' => $this->container->getParameter( 'aimeos_shop.admin' ), |
58
|
|
|
'client' => $this->container->getParameter( 'aimeos_shop.client' ), |
59
|
|
|
'controller' => $this->container->getParameter( 'aimeos_shop.controller' ), |
60
|
|
|
'madmin' => $this->container->getParameter( 'aimeos_shop.madmin' ), |
61
|
|
|
'mshop' => $this->container->getParameter( 'aimeos_shop.mshop' ), |
62
|
|
|
'resource' => $this->container->getParameter( 'aimeos_shop.resource' ), |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$config = new \Aimeos\Base\Config\Decorator\Memory( $conf, $local ); |
66
|
|
|
$settings = $this->container->getParameter( 'aimeos_shop.' . $type ); |
67
|
|
|
|
68
|
|
|
if( is_array( $settings ) && $settings !== [] ) { |
69
|
|
|
$config = new \Aimeos\Base\Config\Decorator\Memory( $config, $settings ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $config; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|