function YamlFileLoader::validate
Same name in this branch
- 11.1.x vendor/symfony/routing/Loader/YamlFileLoader.php \Symfony\Component\Routing\Loader\YamlFileLoader::validate()
- 11.1.x core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php \Drupal\Core\DependencyInjection\YamlFileLoader::validate()
Validates a YAML file.
Throws
InvalidArgumentException When service file is not valid
1 call to YamlFileLoader::validate()
- YamlFileLoader::loadFile in vendor/
symfony/ dependency-injection/ Loader/ YamlFileLoader.php - Loads a YAML file.
File
-
vendor/
symfony/ dependency-injection/ Loader/ YamlFileLoader.php, line 797
Class
- YamlFileLoader
- YamlFileLoader loads YAML files service definitions.
Namespace
Symfony\Component\DependencyInjection\LoaderCode
private function validate(mixed $content, string $file) : ?array {
if (null === $content) {
return $content;
}
if (!\is_array($content)) {
throw new InvalidArgumentException(\sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file));
}
foreach ($content as $namespace => $data) {
if (\in_array($namespace, [
'imports',
'parameters',
'services',
]) || str_starts_with($namespace, 'when@')) {
continue;
}
if (!$this->prepend && !$this->container
->hasExtension($namespace)) {
$extensionNamespaces = array_filter(array_map(fn(ExtensionInterface $ext) => $ext->getAlias(), $this->container
->getExtensions()));
throw new InvalidArgumentException(UndefinedExtensionHandler::getErrorMessage($namespace, $file, $namespace, $extensionNamespaces));
}
}
return $content;
}