1 | <?php |
||
10 | class FileLoader implements LoaderInterface |
||
11 | { |
||
12 | /** |
||
13 | * The filesystem instance. |
||
14 | * |
||
15 | * @var \Magister\Services\Filesystem\Filesystem |
||
16 | */ |
||
17 | protected $files; |
||
18 | |||
19 | /** |
||
20 | * The default configuration path. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $defaultPath; |
||
25 | |||
26 | /** |
||
27 | * All of the named path hints. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $hints = []; |
||
32 | |||
33 | /** |
||
34 | * A cache of whether namespaces and groups exists. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $exists = []; |
||
39 | |||
40 | /** |
||
41 | * Create a new file configuration loader. |
||
42 | * |
||
43 | * @param \Magister\Services\Filesystem\Filesystem $files |
||
44 | * @param string $defaultPath |
||
45 | */ |
||
46 | public function __construct(Filesystem $files, $defaultPath) |
||
51 | |||
52 | /** |
||
53 | * Load the given configuration group. |
||
54 | * |
||
55 | * @param string $group |
||
56 | * @param string $namespace |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | public function load($group, $namespace = null) |
||
78 | |||
79 | /** |
||
80 | * Determine if the given group exists. |
||
81 | * |
||
82 | * @param string $group |
||
83 | * @param string $namespace |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | public function exists($group, $namespace = null) |
||
107 | |||
108 | /** |
||
109 | * Get the configuration path for a namespace. |
||
110 | * |
||
111 | * @param string $namespace |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | protected function getPath($namespace) |
||
123 | |||
124 | /** |
||
125 | * Add a new namespace to the loader. |
||
126 | * |
||
127 | * @param string $namespace |
||
128 | * @param string $hint |
||
129 | * |
||
130 | * @return void |
||
131 | */ |
||
132 | public function addNamespace($namespace, $hint) |
||
136 | |||
137 | /** |
||
138 | * Returns all registered namespaces with the config loader. |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | public function getNamespaces() |
||
146 | |||
147 | /** |
||
148 | * Get a file's contents by requiring it. |
||
149 | * |
||
150 | * @param string $path |
||
151 | * |
||
152 | * @return mixed |
||
153 | */ |
||
154 | protected function getRequire($path) |
||
158 | |||
159 | /** |
||
160 | * Get the filesystem instance. |
||
161 | * |
||
162 | * @return \Magister\Services\Filesystem\Filesystem |
||
163 | */ |
||
164 | public function getFilesystem() |
||
168 | } |
||
169 |