Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. XmlFileLoader.php

function XmlFileLoader::parseDeprecation

Parses the deprecation elements.

Throws

\InvalidArgumentException When the XML is invalid

1 call to XmlFileLoader::parseDeprecation()
XmlFileLoader::parseRoute in vendor/symfony/routing/Loader/XmlFileLoader.php
Parses a route and adds it to the RouteCollection.

File

vendor/symfony/routing/Loader/XmlFileLoader.php, line 433

Class

XmlFileLoader
XmlFileLoader loads XML routing files.

Namespace

Symfony\Component\Routing\Loader

Code

private function parseDeprecation(\DOMElement $node, string $path) : array {
    $deprecatedNode = null;
    foreach ($node->childNodes as $child) {
        if (!$child instanceof \DOMElement || self::NAMESPACE_URI !== $child->namespaceURI) {
            continue;
        }
        if ('deprecated' !== $child->localName) {
            throw new \InvalidArgumentException(\sprintf('Invalid child element "%s" defined for alias "%s" in "%s".', $child->localName, $node->getAttribute('id'), $path));
        }
        $deprecatedNode = $child;
    }
    if (null === $deprecatedNode) {
        return [];
    }
    if (!$deprecatedNode->hasAttribute('package')) {
        throw new \InvalidArgumentException(\sprintf('The <deprecated> element in file "%s" must have a "package" attribute.', $path));
    }
    if (!$deprecatedNode->hasAttribute('version')) {
        throw new \InvalidArgumentException(\sprintf('The <deprecated> element in file "%s" must have a "version" attribute.', $path));
    }
    return [
        'package' => $deprecatedNode->getAttribute('package'),
        'version' => $deprecatedNode->getAttribute('version'),
        'message' => trim($deprecatedNode->nodeValue),
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal