|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://www.gnu.org/copyleft/lgpl.html |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 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 config object |
|
18
|
|
|
* |
|
19
|
|
|
* @package flow |
|
20
|
|
|
* @subpackage Base |
|
21
|
|
|
* @Flow\Scope("singleton") |
|
22
|
|
|
*/ |
|
23
|
|
|
class Config |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var \Aimeos\Shop\Base\Aimeos |
|
27
|
|
|
* @Flow\Inject |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $aimeos; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var array |
|
33
|
|
|
* @Flow\InjectConfiguration(path="persistence.backendOptions", package="Neos.Flow") |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $resource; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var array |
|
39
|
|
|
*/ |
|
40
|
|
|
private $settings; |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Returns the Aimeos object. |
|
45
|
|
|
* |
|
46
|
|
|
* @return \Aimeos\Bootstrap Aimeos object |
|
47
|
|
|
*/ |
|
48
|
|
|
public function get( $type = 'frontend' ) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->settings['resource']['db']['host'] = $this->resource['host']; |
|
51
|
|
|
$this->settings['resource']['db']['database'] = $this->resource['dbname']; |
|
52
|
|
|
$this->settings['resource']['db']['username'] = $this->resource['user']; |
|
53
|
|
|
$this->settings['resource']['db']['password'] = $this->resource['password']; |
|
54
|
|
|
|
|
55
|
|
|
$configPaths = $this->aimeos->get()->getConfigPaths(); |
|
56
|
|
|
$config = new \Aimeos\MW\Config\PHPArray( array(), $configPaths ); |
|
57
|
|
|
|
|
58
|
|
|
$apc = (bool) ( isset( $this->settings['flow']['apc']['enable'] ) ? $this->settings['flow']['apc']['enable'] : false ); |
|
59
|
|
|
$prefix = (string) ( isset( $this->settings['flow']['apc']['prefix'] ) ? $this->settings['flow']['apc']['prefix'] : 'flow:' ); |
|
60
|
|
|
|
|
61
|
|
|
if( $apc === true ) { |
|
62
|
|
|
$config = new \Aimeos\MW\Config\Decorator\APC( $config, $prefix ); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
$config = new \Aimeos\MW\Config\Decorator\Memory( $config, $this->settings ); |
|
66
|
|
|
|
|
67
|
|
|
if( isset( $this->settings[$type] ) ) { |
|
68
|
|
|
$config = new \Aimeos\MW\Config\Decorator\Memory( $config, $this->settings[$type] ); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $config; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Inject the settings |
|
77
|
|
|
* |
|
78
|
|
|
* @param array $settings |
|
79
|
|
|
* @return void |
|
80
|
|
|
*/ |
|
81
|
|
|
public function injectSettings( array $settings ) |
|
82
|
|
|
{ |
|
83
|
|
|
$this->settings = $settings; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|