1 | <?php |
||
25 | class ConfigCache |
||
26 | { |
||
27 | const DEFAULT_ID = 'cache'; |
||
28 | const TAG_CACHE_WARMER = 'config_cache.warmer'; |
||
29 | |||
30 | protected $cache; |
||
31 | protected $loader; |
||
32 | protected $config = array(); |
||
33 | protected $arrayAccess; |
||
34 | protected $configuration; |
||
35 | protected $resources = array(); |
||
36 | // doctrine cache ID |
||
37 | protected $id; |
||
38 | protected $strict = true; |
||
39 | |||
40 | /** |
||
41 | * Constructor. |
||
42 | * |
||
43 | * @param Cache $cache |
||
44 | * @param LoaderInterface $loader |
||
45 | * @param array $config |
||
46 | */ |
||
47 | 12 | public function __construct(Cache $cache, LoaderInterface $loader, array $config = array()) |
|
53 | |||
54 | /** |
||
55 | * Sets a loader. |
||
56 | * |
||
57 | * @param LoaderInterface $loader |
||
58 | * |
||
59 | * @return ConfigCache |
||
60 | */ |
||
61 | 15 | public function setLoader(LoaderInterface $loader) |
|
67 | |||
68 | /** |
||
69 | * Sets a ArrayAccess to find array value using dotted key. |
||
70 | * |
||
71 | * @param ArrayAccessInterface $arrayAccess |
||
72 | * |
||
73 | * @return ConfigCache |
||
74 | */ |
||
75 | 14 | public function setArrayAccess(ArrayAccessInterface $arrayAccess) |
|
81 | |||
82 | /** |
||
83 | * Adds a resource. |
||
84 | * |
||
85 | * @param string $resource |
||
86 | * @param ConfigurationInterface|null $configuration |
||
87 | * |
||
88 | * @return ConfigCache |
||
89 | */ |
||
90 | 40 | public function addResource($resource, ConfigurationInterface $configuration = null) |
|
96 | |||
97 | /** |
||
98 | * Sets a configuration. |
||
99 | * |
||
100 | * @param ConfigurationInterface $configuration |
||
101 | * |
||
102 | * @return ConfigCache |
||
103 | */ |
||
104 | 11 | public function setConfiguration(ConfigurationInterface $configuration) |
|
110 | |||
111 | /** |
||
112 | * Sets a doctrine cache ID (only once). |
||
113 | * |
||
114 | * @param string $id |
||
115 | * |
||
116 | * @return ConfigCache |
||
117 | * |
||
118 | * @throws \RuntimeException |
||
119 | */ |
||
120 | 11 | public function setId($id) |
|
130 | |||
131 | /** |
||
132 | * Sets a strict mode. |
||
133 | * |
||
134 | * @param bool $strict |
||
135 | * |
||
136 | * @return ConfigCache |
||
137 | */ |
||
138 | 12 | public function setStrict($strict) |
|
144 | |||
145 | /** |
||
146 | * Finds cached array. |
||
147 | * |
||
148 | * @param string $key |
||
149 | * @param mixed $default |
||
150 | * |
||
151 | * @return array |
||
152 | */ |
||
153 | 1 | public function find($key, $default = array()) |
|
157 | |||
158 | /** |
||
159 | * Finds All cached array. |
||
160 | * |
||
161 | * @return array |
||
162 | */ |
||
163 | 11 | public function findAll() |
|
172 | |||
173 | /** |
||
174 | * Creates PHP cache file. |
||
175 | */ |
||
176 | 4 | public function create() |
|
182 | |||
183 | /** |
||
184 | * Saves PHP cache file to the temporary directory. |
||
185 | */ |
||
186 | 2 | public function save() |
|
190 | |||
191 | /** |
||
192 | * Restores PHP cache file to the cache directory. |
||
193 | */ |
||
194 | 1 | public function restore() |
|
198 | |||
199 | /** |
||
200 | * Creates PHP cache file internal processing. |
||
201 | * |
||
202 | * @return array |
||
203 | */ |
||
204 | 15 | protected function createInternal() |
|
211 | |||
212 | /** |
||
213 | * Finds a doctrine cache ID. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | 26 | protected function findId() |
|
221 | |||
222 | /** |
||
223 | * Gets a strict mode. |
||
224 | * |
||
225 | * @return bool |
||
226 | */ |
||
227 | 28 | protected function getStrict() |
|
231 | |||
232 | /** |
||
233 | * Whether the mode is strict or not. |
||
234 | * |
||
235 | * @return bool |
||
236 | */ |
||
237 | 27 | protected function isStrict() |
|
241 | |||
242 | /** |
||
243 | * Finds cached array internal processing. |
||
244 | * |
||
245 | * @param array $data |
||
246 | * @param string $key |
||
247 | * @param mixed $default |
||
248 | * |
||
249 | * @return array |
||
250 | */ |
||
251 | 7 | protected function findInternal(array $data, $key, $default = array()) |
|
261 | |||
262 | /** |
||
263 | * Loads config files. |
||
264 | * |
||
265 | * @return array |
||
266 | */ |
||
267 | 28 | protected function load() |
|
290 | |||
291 | /** |
||
292 | * Loads a config file which is not strict mode. |
||
293 | * |
||
294 | * @return array |
||
295 | */ |
||
296 | 3 | protected function loadOne() |
|
300 | |||
301 | /** |
||
302 | * Processes an array of configurations. |
||
303 | * |
||
304 | * @param array $validated validated array |
||
305 | * @param array $validating validating array |
||
306 | * @param ConfigurationInterface $configuration configuration |
||
307 | * @param ArrayNode $masterNode master node |
||
308 | * |
||
309 | * @return array list of (array, ArrayNode) |
||
310 | */ |
||
311 | 28 | protected function processConfiguration( |
|
326 | |||
327 | /** |
||
328 | * Creates master node. |
||
329 | * |
||
330 | * @return ArrayNode |
||
331 | */ |
||
332 | 27 | protected function createMasterNode() |
|
340 | |||
341 | /** |
||
342 | * Finds a restorable cache object. |
||
343 | * |
||
344 | * @return RestorablePhpFileCache |
||
345 | * |
||
346 | * @throws \RuntimeException |
||
347 | */ |
||
348 | 6 | protected function findRestorableCache() |
|
356 | } |
||
357 |