You are here

class YamlFileLoader in Plug 7

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

YamlFileLoader loads translations from Yaml files.

@author Fabien Potencier <fabien@symfony.com>

@api

Hierarchy

Expanded class hierarchy of YamlFileLoader

1 file declares its use of YamlFileLoader
YamlFileLoaderTest.php in lib/Symfony/translation/Tests/Loader/YamlFileLoaderTest.php
1 string reference to 'YamlFileLoader'
TranslatorTest::getTransFileTests in lib/Symfony/translation/Tests/TranslatorTest.php

File

lib/Symfony/translation/Loader/YamlFileLoader.php, line 25

Namespace

Symfony\Component\Translation\Loader
View source
class YamlFileLoader extends FileLoader {
  private $yamlParser;

  /**
   * {@inheritdoc}
   */
  protected function loadResource($resource) {
    if (null === $this->yamlParser) {
      if (!class_exists('Symfony\\Component\\Yaml\\Parser')) {
        throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
      }
      $this->yamlParser = new YamlParser();
    }
    try {
      $messages = $this->yamlParser
        ->parse(file_get_contents($resource));
    } catch (ParseException $e) {
      throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e);
    }
    return $messages;
  }

}

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
YamlFileLoader::$yamlParser private property
YamlFileLoader::loadResource protected function Overrides FileLoader::loadResource