function YamlFileLoader::load
Same name in other branches
- 9 core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::load()
- 10 core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::load()
- 11.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::load()
Loads a Yaml file.
Parameters
mixed $file: The resource
File
-
core/
lib/ Drupal/ Core/ DependencyInjection/ YamlFileLoader.php, line 58
Class
- YamlFileLoader
- YamlFileLoader loads YAML files service definitions.
Namespace
Drupal\Core\DependencyInjectionCode
public function load($file) {
// Load from the file cache, fall back to loading the file.
$content = $this->fileCache
->get($file);
if (!$content) {
$content = $this->loadFile($file);
$this->fileCache
->set($file, $content);
}
// Not supported.
//$this->container->addResource(new FileResource($path));
// empty file
if (null === $content) {
return;
}
// imports
// Not supported.
//$this->parseImports($content, $file);
// parameters
if (isset($content['parameters'])) {
if (!is_array($content['parameters'])) {
throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $file));
}
foreach ($content['parameters'] as $key => $value) {
$this->container
->setParameter($key, $this->resolveServices($value));
}
}
// extensions
// Not supported.
//$this->loadFromExtensions($content);
// services
$this->parseDefinitions($content, $file);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.