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

Breadcrumb

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

function XmlDescriptor::getApplicationDocument

1 call to XmlDescriptor::getApplicationDocument()
XmlDescriptor::describeApplication in vendor/symfony/console/Descriptor/XmlDescriptor.php
Describes an Application instance.

File

vendor/symfony/console/Descriptor/XmlDescriptor.php, line 82

Class

XmlDescriptor
XML descriptor.

Namespace

Symfony\Component\Console\Descriptor

Code

public function getApplicationDocument(Application $application, ?string $namespace = null, bool $short = false) : \DOMDocument {
    $dom = new \DOMDocument('1.0', 'UTF-8');
    $dom->appendChild($rootXml = $dom->createElement('symfony'));
    if ('UNKNOWN' !== $application->getName()) {
        $rootXml->setAttribute('name', $application->getName());
        if ('UNKNOWN' !== $application->getVersion()) {
            $rootXml->setAttribute('version', $application->getVersion());
        }
    }
    $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
    $description = new ApplicationDescription($application, $namespace, true);
    if ($namespace) {
        $commandsXML->setAttribute('namespace', $namespace);
    }
    foreach ($description->getCommands() as $command) {
        $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short));
    }
    if (!$namespace) {
        $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
        foreach ($description->getNamespaces() as $namespaceDescription) {
            $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
            $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
            foreach ($namespaceDescription['commands'] as $name) {
                $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
                $commandXML->appendChild($dom->createTextNode($name));
            }
        }
    }
    return $dom;
}
RSS feed
Powered by Drupal