You are here

private function XmlFileLoader::validateExtensions in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/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 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
Parses a XML file to a \DOMDocument.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php, line 504

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