You are here

protected function YamlFileLoader::loadFile in Service Container 7.2

Same name in this branch
  1. 7.2 lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::loadFile()
  2. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php \Symfony\Component\DependencyInjection\Loader\YamlFileLoader::loadFile()
Same name and namespace in other branches
  1. 7 lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\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 lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Loads a Yaml file.

File

lib/Drupal/Core/DependencyInjection/YamlFileLoader.php, line 293
Contains \Drupal\Core\DependencyInjection\YamlFileLoader.

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));
  }
  return $this
    ->validate(Yaml::decode(file_get_contents($file)), $file);
}