1 | <?php |
||
26 | abstract class AbstractConfig extends Data |
||
27 | { |
||
28 | const IMPORTS = 'imports'; |
||
29 | const FILECHECK = 'filecheck'; |
||
30 | const FILE = 'file'; |
||
31 | const RESOURCE = 'resource'; |
||
32 | const DEFAULT = 'default'; |
||
33 | const DEFAULT_ENVIRONMENT = 'defaultEnv'; |
||
34 | const ENVIRONMENT = 'env'; |
||
35 | |||
36 | /** |
||
37 | * @var bool |
||
38 | */ |
||
39 | protected $filecheck = true; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $currentBasepath; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $imports = []; |
||
50 | |||
51 | /** |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $default = []; |
||
55 | |||
56 | /** |
||
57 | * Default constructor. |
||
58 | * |
||
59 | * @param array $param |
||
60 | */ |
||
61 | public function __construct(array $param) |
||
69 | |||
70 | /** |
||
71 | * Add named property to config object |
||
72 | * and insert config as array. |
||
73 | * |
||
74 | * @param string $name name of property |
||
75 | * @param string $file string $file absolute filepath/filename.ending |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function addConfig(string $name, string $file) |
||
84 | |||
85 | /** |
||
86 | * Read config file via YAML parser. |
||
87 | * |
||
88 | * @param string $file absolute filepath/filename.ending |
||
89 | * @return array config array |
||
90 | */ |
||
91 | public function readConfig(string $file) : array |
||
105 | |||
106 | /** |
||
107 | * Add config to data storage. |
||
108 | * |
||
109 | * @param string $file absolute filepath/filename.ending |
||
110 | * @return $this |
||
111 | */ |
||
112 | public function setConfig(string $file) |
||
123 | |||
124 | /** |
||
125 | * Read yaml files. |
||
126 | * |
||
127 | * @param string $file path/filename |
||
128 | * @return array |
||
129 | */ |
||
130 | private function readFile(string $file) : array |
||
144 | |||
145 | /** |
||
146 | * get all import files from config, if set and remove node. |
||
147 | * |
||
148 | * @param array $config |
||
149 | * @return array |
||
150 | */ |
||
151 | private function extractImports(array $config) : array |
||
171 | |||
172 | /** |
||
173 | * Get default values if set and remove node from config. |
||
174 | * |
||
175 | * @param array $config |
||
176 | * @return array |
||
177 | */ |
||
178 | private function extractDefault(array $config) : array |
||
187 | |||
188 | /** |
||
189 | * Prepare the defaults and replace recursively. |
||
190 | */ |
||
191 | private function mergeDefault() |
||
195 | |||
196 | /** |
||
197 | * Only add basepath if not already in filename. |
||
198 | * |
||
199 | * @param string $include |
||
200 | * @return string |
||
201 | */ |
||
202 | private function checkPath(string $include) : string |
||
210 | } |
||
211 |