You are here

abstract class FileLoader in Plug 7

Same name in this branch
  1. 7 lib/Symfony/translation/Loader/FileLoader.php \Symfony\Component\Translation\Loader\FileLoader
  2. 7 lib/Symfony/validator/Symfony/Component/Validator/Mapping/Loader/FileLoader.php \Symfony\Component\Validator\Mapping\Loader\FileLoader

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

Hierarchy

Expanded class hierarchy of FileLoader

File

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

Namespace

Symfony\Component\Translation\Loader
View source
abstract class FileLoader extends ArrayLoader {

  /**
   * {@inheritdoc}
   */
  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;
  }

  /*
   * @param string $resource
   *
   * @return array
   *
   * @throws InvalidResourceException If stream content has an invalid format.
   */
  protected abstract function loadResource($resource);

}

Members

Namesort descending Modifiers Type Description Overrides
ArrayLoader::flatten private function Flattens an nested array of translations.
FileLoader::load public function @api Overrides ArrayLoader::load
FileLoader::loadResource abstract protected function 7