You are here

public function XmlDumper::dump in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php \Symfony\Component\DependencyInjection\Dumper\XmlDumper::dump()

Dumps the service container as an XML string.

@api

Parameters

array $options An array of options:

Return value

string An xml string representing of the service container

Overrides DumperInterface::dump

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php, line 46

Class

XmlDumper
XmlDumper dumps a service container as an XML string.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

public function dump(array $options = array()) {
  $this->document = new \DOMDocument('1.0', 'utf-8');
  $this->document->formatOutput = true;
  $container = $this->document
    ->createElementNS('http://symfony.com/schema/dic/services', 'container');
  $container
    ->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
  $container
    ->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd');
  $this
    ->addParameters($container);
  $this
    ->addServices($container);
  $this->document
    ->appendChild($container);
  $xml = $this->document
    ->saveXML();
  $this->document = null;
  return $xml;
}