@@ 251-266 (lines=16) @@ | ||
248 | return $this->storage->exists($path); |
|
249 | } |
|
250 | ||
251 | private function loadFile($path, $className, array $options = array()) |
|
252 | { |
|
253 | $json = $this->storage->read($path); |
|
254 | $jsonData = $this->decode($json, $path); |
|
255 | $options['path'] = $path; |
|
256 | ||
257 | try { |
|
258 | return $this->converterProvider->getJsonConverter($className)->fromJson($jsonData, $options); |
|
259 | } catch (ConversionFailedException $e) { |
|
260 | throw new InvalidConfigException(sprintf( |
|
261 | 'The JSON in %s could not be converted: %s', |
|
262 | $path, |
|
263 | $e->getMessage() |
|
264 | ), 0, $e); |
|
265 | } |
|
266 | } |
|
267 | ||
268 | private function saveFile($file, $path, array $options = array()) |
|
269 | { |
|
@@ 268-285 (lines=18) @@ | ||
265 | } |
|
266 | } |
|
267 | ||
268 | private function saveFile($file, $path, array $options = array()) |
|
269 | { |
|
270 | $className = get_class($file); |
|
271 | ||
272 | try { |
|
273 | $jsonData = $this->converterProvider->getJsonConverter($className)->toJson($file, $options); |
|
274 | } catch (ConversionFailedException $e) { |
|
275 | throw new InvalidConfigException(sprintf( |
|
276 | 'The data written to %s could not be converted: %s', |
|
277 | $path, |
|
278 | $e->getMessage() |
|
279 | ), 0, $e); |
|
280 | } |
|
281 | ||
282 | $json = $this->encode($jsonData, $path); |
|
283 | ||
284 | $this->storage->write($path, $json); |
|
285 | } |
|
286 | ||
287 | private function encode(stdClass $jsonData, $path) |
|
288 | { |