1 | <?php |
||
28 | class Config |
||
29 | { |
||
30 | /** |
||
31 | * @var array config data |
||
32 | */ |
||
33 | private $config = array(); |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $partialConfig = array(); |
||
39 | |||
40 | /** |
||
41 | * @var ConfigurationLoader |
||
42 | */ |
||
43 | private $loader; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | private $initConfig; |
||
49 | |||
50 | /** |
||
51 | * @var boolean |
||
52 | */ |
||
53 | private $isPharMode; |
||
54 | |||
55 | /** |
||
56 | * @var OutputInterface |
||
57 | */ |
||
58 | private $output; |
||
59 | |||
60 | /** |
||
61 | * Config constructor. |
||
62 | * |
||
63 | * @param array $initConfig |
||
64 | * @param bool $isPharMode |
||
65 | * @param OutputInterface $output [optional] |
||
66 | */ |
||
67 | public function __construct(array $initConfig = array(), $isPharMode = false, OutputInterface $output = null) |
||
73 | |||
74 | /** |
||
75 | * alias magerun command in input from config |
||
76 | * |
||
77 | * @param InputInterface $input |
||
78 | * @return ArgvInput|InputInterface |
||
79 | */ |
||
80 | public function checkConfigCommandAlias(InputInterface $input) |
||
107 | |||
108 | /** |
||
109 | * @param Command $command |
||
110 | */ |
||
111 | public function registerConfigCommandAlias(Command $command) |
||
128 | |||
129 | /** |
||
130 | * @param Application $application |
||
131 | */ |
||
132 | public function registerCustomCommands(Application $application) |
||
152 | |||
153 | /** |
||
154 | * @param string $className |
||
155 | * @param string|null $commandName |
||
156 | * @return Command |
||
157 | * @throws InvalidArgumentException |
||
158 | */ |
||
159 | private function newCommand($className, $commandName) |
||
175 | |||
176 | /** |
||
177 | * Adds autoloader prefixes from user's config |
||
178 | * |
||
179 | * @param ClassLoader $autoloader |
||
180 | */ |
||
181 | public function registerCustomAutoloaders(ClassLoader $autoloader) |
||
195 | |||
196 | /** |
||
197 | * @param array $config |
||
198 | */ |
||
199 | public function setConfig(array $config) |
||
203 | |||
204 | /** |
||
205 | * @return array |
||
206 | */ |
||
207 | public function getConfig() |
||
211 | |||
212 | /** |
||
213 | * @param ConfigurationLoader $configurationLoader |
||
214 | */ |
||
215 | public function setLoader(ConfigurationLoader $configurationLoader) |
||
219 | |||
220 | /** |
||
221 | * @return ConfigurationLoader |
||
222 | */ |
||
223 | public function getLoader() |
||
232 | |||
233 | public function load() |
||
237 | |||
238 | /** |
||
239 | * @param bool $loadExternalConfig |
||
240 | */ |
||
241 | public function loadPartialConfig($loadExternalConfig) |
||
246 | |||
247 | /** |
||
248 | * Get names of sub-folders to be scanned during Magento detection |
||
249 | * |
||
250 | * @return array |
||
251 | */ |
||
252 | public function getDetectSubFolders() |
||
260 | |||
261 | /** |
||
262 | * @param array $initConfig |
||
263 | * @param bool $isPharMode |
||
264 | * @param OutputInterface $output |
||
265 | * |
||
266 | * @return ConfigurationLoader |
||
267 | */ |
||
268 | public function createLoader(array $initConfig, $isPharMode, OutputInterface $output) |
||
276 | |||
277 | /** |
||
278 | * @param string $message |
||
279 | */ |
||
280 | private function debugWriteln($message) |
||
287 | |||
288 | /** |
||
289 | * Get array from config, default to an empty array if not set |
||
290 | * |
||
291 | * @param string|array $key |
||
292 | * @param array $default [optional] |
||
293 | * @return array |
||
294 | */ |
||
295 | private function getArray($key, $default = array()) |
||
304 | |||
305 | private function traverse(array $keys) |
||
321 | } |
||
322 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: