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