1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the puli/manager package. |
5
|
|
|
* |
6
|
|
|
* (c) Bernhard Schussek <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Puli\Manager\Config; |
13
|
|
|
|
14
|
|
|
use Puli\Manager\Api\Config\ConfigFile; |
15
|
|
|
use Puli\Manager\Api\Config\ConfigFileManager; |
16
|
|
|
use Puli\Manager\Api\Context\Context; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Manages changes to the global configuration file. |
20
|
|
|
* |
21
|
|
|
* Use this class to make persistent changes to the global config.json. |
22
|
|
|
* Whenever you call methods in this class, the changes will be written to disk. |
23
|
|
|
* |
24
|
|
|
* @since 1.0 |
25
|
|
|
* |
26
|
|
|
* @author Bernhard Schussek <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
class ConfigFileManagerImpl extends AbstractConfigManager implements ConfigFileManager |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var Context |
32
|
|
|
*/ |
33
|
|
|
private $context; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var ConfigFile |
37
|
|
|
*/ |
38
|
|
|
private $configFile; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var ConfigFileStorage |
42
|
|
|
*/ |
43
|
|
|
private $configFileStorage; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Creates the configuration manager. |
47
|
|
|
* |
48
|
|
|
* @param Context $context The global context. |
49
|
|
|
* @param ConfigFileStorage $configFileStorage The configuration file storage. |
50
|
|
|
*/ |
51
|
36 |
|
public function __construct(Context $context, ConfigFileStorage $configFileStorage) |
52
|
|
|
{ |
53
|
36 |
|
$this->context = $context; |
54
|
36 |
|
$this->configFileStorage = $configFileStorage; |
55
|
36 |
|
$this->configFile = $context->getConfigFile(); |
56
|
36 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
35 |
|
public function getConfig() |
62
|
|
|
{ |
63
|
35 |
|
return $this->configFile->getConfig(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
|
|
public function getContext() |
70
|
|
|
{ |
71
|
|
|
return $this->context; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* {@inheritdoc} |
76
|
|
|
*/ |
77
|
|
|
public function getConfigFile() |
78
|
|
|
{ |
79
|
|
|
return $this->configFile; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* {@inheritdoc} |
84
|
|
|
*/ |
85
|
13 |
|
protected function saveConfigFile() |
86
|
|
|
{ |
87
|
13 |
|
$this->configFileStorage->saveConfigFile($this->configFile); |
88
|
7 |
|
} |
89
|
|
|
} |
90
|
|
|
|