|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Composer plugin for config assembling |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/composer-config-plugin |
|
6
|
|
|
* @package composer-config-plugin |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2016-2018, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hiqdev\composer\config\configs; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* System class represents system configuration files: |
|
15
|
|
|
* __files, aliases, packages. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Andrii Vasyliev <[email protected]> |
|
18
|
|
|
* |
|
19
|
|
|
* @since php5.5 |
|
20
|
|
|
*/ |
|
21
|
|
|
class System extends Config |
|
22
|
|
|
{ |
|
23
|
|
|
public function setValue($name, $value) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->values[$name] = $value; |
|
26
|
|
|
|
|
27
|
|
|
return $this; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function setValues(array $values) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->values = $values; |
|
33
|
|
|
|
|
34
|
|
|
return $this; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function mergeValues(array $values) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->values = array_merge($this->values, $values); |
|
40
|
|
|
|
|
41
|
|
|
return $this; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string $path |
|
46
|
|
|
* @param array $data |
|
47
|
|
|
* @throws \ReflectionException |
|
48
|
|
|
* @throws \hiqdev\composer\config\exceptions\FailedWriteException |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function writeFile($path, array $data) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->writePhpFile($path, $data, false, false); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function load(array $paths = []) |
|
56
|
|
|
{ |
|
57
|
|
|
$path = $this->getOutputPath(); |
|
58
|
|
|
if (!file_exists($path)) { |
|
59
|
|
|
return $this; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$this->values = array_merge($this->loadFile($path), $this->values); |
|
63
|
|
|
|
|
64
|
|
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function build() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->values = $this->substituteOutputDirs($this->values); |
|
70
|
|
|
|
|
71
|
|
|
return $this; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|