You are here

protected function YamlFileLoader::loadResource in Plug 7

Overrides FileLoader::loadResource

File

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

Class

YamlFileLoader
YamlFileLoader loads translations from Yaml files.

Namespace

Symfony\Component\Translation\Loader

Code

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;
}