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

Breadcrumb

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

function YamlFileLoader::loadFile

Same name in this branch
  1. 11.1.x vendor/symfony/dependency-injection/Loader/YamlFileLoader.php \Symfony\Component\DependencyInjection\Loader\YamlFileLoader::loadFile()

Loads a YAML file.

Parameters

string $file:

Return value

array The file content

Throws

InvalidArgumentException When the given file is not a local file or when it does not exist.

1 call to YamlFileLoader::loadFile()
YamlFileLoader::load in core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Loads a Yaml file.

File

core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php, line 438

Class

YamlFileLoader
YamlFileLoader loads YAML files service definitions.

Namespace

Drupal\Core\DependencyInjection

Code

protected function loadFile($file) {
    if (!stream_is_local($file)) {
        throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
    }
    if (!file_exists($file)) {
        throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
    }
    try {
        $valid_file = $this->validate(Yaml::decode(file_get_contents($file)), $file);
    } catch (InvalidDataTypeException $e) {
        throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: ', $file) . $e->getMessage());
    }
    return $valid_file;
}

API Navigation

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