You are here

public function FileLoader::load in Plug 7

@api

Overrides ArrayLoader::load

File

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

Class

FileLoader
@author Abdellatif Ait boudad <a.aitboudad@gmail.com>

Namespace

Symfony\Component\Translation\Loader

Code

public function load($resource, $locale, $domain = 'messages') {
  if (!stream_is_local($resource)) {
    throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
  }
  if (!file_exists($resource)) {
    throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
  }
  $messages = $this
    ->loadResource($resource);

  // empty resource
  if (null === $messages) {
    $messages = array();
  }

  // not an array
  if (!is_array($messages)) {
    throw new InvalidResourceException(sprintf('Unable to load file "%s".', $resource));
  }
  $catalogue = parent::load($messages, $locale, $domain);
  if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
    $catalogue
      ->addResource(new FileResource($resource));
  }
  return $catalogue;
}