You are here

private function YamlFileLoader::parseFile in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php \Symfony\Component\Validator\Mapping\Loader\YamlFileLoader::parseFile()

Loads the YAML class descriptions from the given file.

Parameters

string $path The path of the YAML file:

Return value

array|null The class descriptions or null, if the file was empty

Throws

\InvalidArgumentException If the file could not be loaded or did not contain a YAML array

1 call to YamlFileLoader::parseFile()
YamlFileLoader::loadClassMetadata in vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php
Loads validation metadata into a {@link ClassMetadata} instance.

File

vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php, line 119

Class

YamlFileLoader
Loads validation metadata from a YAML file.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

private function parseFile($path) {
  try {
    $classes = $this->yamlParser
      ->parse(file_get_contents($path));
  } catch (ParseException $e) {
    throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
  }

  // empty file
  if (null === $classes) {
    return;
  }

  // not an array
  if (!is_array($classes)) {
    throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
  }
  return $classes;
}