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 | * @throws \RuntimeException |
||
187 | */ |
||
188 | 2 | public function save() |
|
192 | |||
193 | /** |
||
194 | * Restores PHP cache file to the cache directory. |
||
195 | * |
||
196 | * @throws \RuntimeException |
||
197 | */ |
||
198 | 1 | public function restore() |
|
202 | |||
203 | /** |
||
204 | * Creates PHP cache file internal processing. |
||
205 | * |
||
206 | * @return array |
||
207 | */ |
||
208 | 15 | protected function createInternal() |
|
215 | |||
216 | /** |
||
217 | * Finds a doctrine cache ID. |
||
218 | * |
||
219 | * @return string |
||
220 | */ |
||
221 | 26 | protected function findId() |
|
225 | |||
226 | /** |
||
227 | * Whether the mode is strict or not. |
||
228 | * |
||
229 | * @return bool |
||
230 | */ |
||
231 | 28 | protected function isStrict() |
|
235 | |||
236 | /** |
||
237 | * Finds cached array internal processing. |
||
238 | * |
||
239 | * @param array $data |
||
240 | * @param string $key |
||
241 | * @param mixed $default |
||
242 | * |
||
243 | * @return array |
||
244 | */ |
||
245 | 7 | protected function findInternal(array $data, $key, $default = array()) |
|
255 | |||
256 | /** |
||
257 | * Loads config files. |
||
258 | * |
||
259 | * @return array |
||
260 | */ |
||
261 | 28 | protected function load() |
|
284 | |||
285 | /** |
||
286 | * Loads a config file which is not strict mode. |
||
287 | * |
||
288 | * @return array |
||
289 | */ |
||
290 | 3 | protected function loadOne() |
|
294 | |||
295 | /** |
||
296 | * Processes an array of configurations. |
||
297 | * |
||
298 | * @param array $validated validated array |
||
299 | * @param array $validating validating array |
||
300 | * @param ConfigurationInterface $configuration configuration |
||
301 | * @param ArrayNode $masterNode master node |
||
302 | * |
||
303 | * @return array list of (array, ArrayNode) |
||
304 | */ |
||
305 | 28 | protected function processConfiguration( |
|
320 | |||
321 | /** |
||
322 | * Creates master node. |
||
323 | * |
||
324 | * @return ArrayNode |
||
325 | */ |
||
326 | 27 | protected function createMasterNode() |
|
334 | |||
335 | /** |
||
336 | * Finds a restorable cache object. |
||
337 | * |
||
338 | * @return RestorablePhpFileCache |
||
339 | * |
||
340 | * @throws \RuntimeException |
||
341 | */ |
||
342 | 6 | protected function findRestorableCache() |
|
350 | } |
||
351 |