You are here

protected function JsonFileLoader::loadResource in Plug 7

Overrides FileLoader::loadResource

File

lib/Symfony/translation/Loader/JsonFileLoader.php, line 26

Class

JsonFileLoader
JsonFileLoader loads translations from an json file.

Namespace

Symfony\Component\Translation\Loader

Code

protected function loadResource($resource) {
  $messages = array();
  if ($data = file_get_contents($resource)) {
    $messages = json_decode($data, true);
    if (0 < ($errorCode = json_last_error())) {
      throw new InvalidResourceException(sprintf('Error parsing JSON - %s', $this
        ->getJSONErrorMessage($errorCode)));
    }
  }
  return $messages;
}