1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Aimeos\Shop\Base; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Service providing the config object |
13
|
|
|
*/ |
14
|
|
|
class Config |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var \Aimeos\Shop\Base\Config[] |
18
|
|
|
*/ |
19
|
|
|
private $objects = []; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var \Aimeos\Shop\Base\Aimeos |
23
|
|
|
*/ |
24
|
|
|
private $aimeos; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var \Illuminate\Contracts\Config\Repository |
28
|
|
|
*/ |
29
|
|
|
private $config; |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Initializes the object |
34
|
|
|
* |
35
|
|
|
* @param \Illuminate\Contracts\Config\Repository $config Configuration object |
36
|
|
|
* @param \Aimeos\Shop\Base\Aimeos $aimeos Aimeos object |
37
|
|
|
*/ |
38
|
|
|
public function __construct( \Illuminate\Contracts\Config\Repository $config, \Aimeos\Shop\Base\Aimeos $aimeos ) |
39
|
|
|
{ |
40
|
|
|
$this->aimeos = $aimeos; |
41
|
|
|
$this->config = $config; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Creates a new configuration object. |
47
|
|
|
* |
48
|
|
|
* @param string $type Configuration type ("frontend" or "backend") |
49
|
|
|
* @return \Aimeos\Base\Config\Iface Configuration object |
50
|
|
|
*/ |
51
|
|
|
public function get( string $type = 'frontend' ) : \Aimeos\Base\Config\Iface |
52
|
|
|
{ |
53
|
|
|
if( !isset( $this->objects[$type] ) ) |
54
|
|
|
{ |
55
|
|
|
$configPaths = $this->aimeos->get()->getConfigPaths(); |
56
|
|
|
$cfgfile = dirname( dirname( __DIR__ ) ) . '/config/default.php'; |
57
|
|
|
|
58
|
|
|
$config = new \Aimeos\Base\Config\PHPArray( require $cfgfile, $configPaths ); |
59
|
|
|
|
60
|
|
|
if( $this->config->get( 'shop.apc_enabled', false ) == true ) { |
61
|
|
|
$config = new \Aimeos\Base\Config\Decorator\APC( $config, $this->config->get( 'shop.apc_prefix', 'laravel:' ) ); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$config = new \Aimeos\Base\Config\Decorator\Memory( $config, $this->config->get( 'shop' ) ); |
65
|
|
|
|
66
|
|
|
if( ( $conf = $this->config->get( 'shop.' . $type, array() ) ) !== array() ) { |
67
|
|
|
$config = new \Aimeos\Base\Config\Decorator\Memory( $config, $conf ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$this->objects[$type] = $config; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return $this->objects[$type]; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|