function YamlFileLoader::parseDefinitions
Same name in other branches
- 9 core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::parseDefinitions()
- 8.9.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::parseDefinitions()
- 11.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::parseDefinitions()
Parses definitions
Parameters
array $content:
string $file:
1 call to YamlFileLoader::parseDefinitions()
- YamlFileLoader::load in core/
lib/ Drupal/ Core/ DependencyInjection/ YamlFileLoader.php - Loads a Yaml file.
File
-
core/
lib/ Drupal/ Core/ DependencyInjection/ YamlFileLoader.php, line 116
Class
- YamlFileLoader
- YamlFileLoader loads YAML files service definitions.
Namespace
Drupal\Core\DependencyInjectionCode
private function parseDefinitions($content, $file) {
if (!isset($content['services'])) {
return;
}
if (!is_array($content['services'])) {
throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file));
}
// Some extensions split up their dependencies into multiple files.
if (isset($content['_provider'])) {
$provider = $content['_provider'];
}
else {
$basename = basename($file);
[
$provider,
] = explode('.', $basename, 2);
}
$defaults = $this->parseDefaults($content, $file);
$defaults['tags'][] = [
'name' => '_provider',
'provider' => $provider,
];
foreach ($content['services'] as $id => $service) {
$this->parseDefinition($id, $service, $file, $defaults);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.