Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. YamlFileLoader.php

function YamlFileLoader::parseFile

Loads the YAML class descriptions from the given file.

Throws

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

1 call to YamlFileLoader::parseFile()
YamlFileLoader::loadClassesFromYaml in vendor/symfony/validator/Mapping/Loader/YamlFileLoader.php

File

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

Class

YamlFileLoader
Loads validation metadata from a YAML file.

Namespace

Symfony\Component\Validator\Mapping\Loader

Code

private function parseFile(string $path) : array {
    try {
        $classes = $this->yamlParser
            ->parseFile($path, Yaml::PARSE_CONSTANT);
    } catch (ParseException $e) {
        throw new \InvalidArgumentException(\sprintf('The file "%s" does not contain valid YAML: ', $path) . $e->getMessage(), 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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal