You are here

private function XmlFileLoader::validateExtensions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Loader/XmlFileLoader.php \Symfony\Component\DependencyInjection\Loader\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::parseFileToDOM in vendor/symfony/dependency-injection/Loader/XmlFileLoader.php
Parses a XML file to a \DOMDocument.

File

vendor/symfony/dependency-injection/Loader/XmlFileLoader.php, line 503

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'));
    }
  }
}