private function XmlFileLoader::validateExtensions

Validates an extension.

Parameters

\DOMDocument $dom:

string $file:

Throws

InvalidArgumentException When no extension is found corresponding to a tag

1 call to XmlFileLoader::validateExtensions()
XmlFileLoader::validate in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
Validates an XML document.

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php, line 383

Class

XmlFileLoader
XmlFileLoader loads XML files service definitions.

Namespace

Symfony\Component\DependencyInjection\Loader

Code

private function validateExtensions(\DOMDocument $dom, $file) {
  foreach ($dom->documentElement->childNodes as $node) {
    if (!$node instanceof \DOMElement || 'http://symfony.com/schema/dic/services' === $node->namespaceURI) {
      continue;
    }

    // can it be handled by an extension?
    if (!$this->container
      ->hasExtension($node->namespaceURI)) {
      $extensionNamespaces = array_filter(array_map(function ($ext) {
        return $ext
          ->getNamespace();
      }, $this->container
        ->getExtensions()));
      throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'));
    }
  }
}