private function XmlDumper::convertParameters in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php \Symfony\Component\DependencyInjection\Dumper\XmlDumper::convertParameters()
Converts parameters.
Parameters
array $parameters:
string $type:
\DOMElement $parent:
string $keyAttribute:
3 calls to XmlDumper::convertParameters()
- XmlDumper::addMethodCalls in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ XmlDumper.php - Adds method calls.
- XmlDumper::addParameters in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ XmlDumper.php - Adds parameters.
- XmlDumper::addService in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ XmlDumper.php - Adds a service.
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Dumper/ XmlDumper.php, line 265
Class
- XmlDumper
- XmlDumper dumps a service container as an XML string.
Namespace
Symfony\Component\DependencyInjection\DumperCode
private function convertParameters($parameters, $type, \DOMElement $parent, $keyAttribute = 'key') {
$withKeys = array_keys($parameters) !== range(0, count($parameters) - 1);
foreach ($parameters as $key => $value) {
$element = $this->document
->createElement($type);
if ($withKeys) {
$element
->setAttribute($keyAttribute, $key);
}
if (is_array($value)) {
$element
->setAttribute('type', 'collection');
$this
->convertParameters($value, $type, $element, 'key');
}
elseif ($value instanceof Reference) {
$element
->setAttribute('type', 'service');
$element
->setAttribute('id', (string) $value);
$behaviour = $value
->getInvalidBehavior();
if ($behaviour == ContainerInterface::NULL_ON_INVALID_REFERENCE) {
$element
->setAttribute('on-invalid', 'null');
}
elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
$element
->setAttribute('on-invalid', 'ignore');
}
if (!$value
->isStrict()) {
$element
->setAttribute('strict', 'false');
}
}
elseif ($value instanceof Definition) {
$element
->setAttribute('type', 'service');
$this
->addService($value, null, $element);
}
elseif ($value instanceof Expression) {
$element
->setAttribute('type', 'expression');
$text = $this->document
->createTextNode(self::phpToXml((string) $value));
$element
->appendChild($text);
}
else {
if (in_array($value, array(
'null',
'true',
'false',
), true)) {
$element
->setAttribute('type', 'string');
}
$text = $this->document
->createTextNode(self::phpToXml($value));
$element
->appendChild($text);
}
$parent
->appendChild($element);
}
}