namespace Symfony\Component\DependencyInjection\Dumper;
+use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
+use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
+use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;
/**
* Dumps the service container as an XML string.
*
- * @param array $options An array of options
- *
* @return string An xml string representing of the service container
*/
public function dump(array $options = array())
$xml = $this->document->saveXML();
$this->document = null;
- return $xml;
+ return $this->container->resolveEnvPlaceholders($xml);
}
- /**
- * Adds parameters.
- *
- * @param \DOMElement $parent
- */
private function addParameters(\DOMElement $parent)
{
$data = $this->container->getParameterBag()->all();
return;
}
- if ($this->container->isFrozen()) {
+ if ($this->container->isCompiled()) {
$data = $this->escape($data);
}
$this->convertParameters($data, 'parameter', $parameters);
}
- /**
- * Adds method calls.
- *
- * @param array $methodcalls
- * @param \DOMElement $parent
- */
private function addMethodCalls(array $methodcalls, \DOMElement $parent)
{
foreach ($methodcalls as $methodcall) {
$service->setAttribute('class', $class);
}
- if ($definition->getFactoryMethod(false)) {
- $service->setAttribute('factory-method', $definition->getFactoryMethod(false));
- }
- if ($definition->getFactoryClass(false)) {
- $service->setAttribute('factory-class', $definition->getFactoryClass(false));
- }
- if ($definition->getFactoryService(false)) {
- $service->setAttribute('factory-service', $definition->getFactoryService(false));
- }
if (!$definition->isShared()) {
$service->setAttribute('shared', 'false');
}
- if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) {
- $service->setAttribute('scope', $scope);
- }
- if (!$definition->isPublic()) {
- $service->setAttribute('public', 'false');
+ if (!$definition->isPrivate()) {
+ $service->setAttribute('public', $definition->isPublic() ? 'true' : 'false');
}
if ($definition->isSynthetic()) {
$service->setAttribute('synthetic', 'true');
}
- if ($definition->isSynchronized(false)) {
- $service->setAttribute('synchronized', 'true');
- }
if ($definition->isLazy()) {
$service->setAttribute('lazy', 'true');
}
$this->addService($callable[0], null, $factory);
$factory->setAttribute('method', $callable[1]);
} elseif (is_array($callable)) {
- $factory->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
+ if (null !== $callable[0]) {
+ $factory->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
+ }
$factory->setAttribute('method', $callable[1]);
} else {
$factory->setAttribute('function', $callable);
$service->setAttribute('autowire', 'true');
}
- foreach ($definition->getAutowiringTypes() as $autowiringTypeValue) {
+ foreach ($definition->getAutowiringTypes(false) as $autowiringTypeValue) {
$autowiringType = $this->document->createElement('autowiring-type');
$autowiringType->appendChild($this->document->createTextNode($autowiringTypeValue));
$service->appendChild($autowiringType);
}
+ if ($definition->isAutoconfigured()) {
+ $service->setAttribute('autoconfigure', 'true');
+ }
+
+ if ($definition->isAbstract()) {
+ $service->setAttribute('abstract', 'true');
+ }
+
if ($callable = $definition->getConfigurator()) {
$configurator = $this->document->createElement('configurator');
$service = $this->document->createElement('service');
$service->setAttribute('id', $alias);
$service->setAttribute('alias', $id);
- if (!$id->isPublic()) {
- $service->setAttribute('public', 'false');
+ if (!$id->isPrivate()) {
+ $service->setAttribute('public', $id->isPublic() ? 'true' : 'false');
}
$parent->appendChild($service);
}
- /**
- * Adds services.
- *
- * @param \DOMElement $parent
- */
private function addServices(\DOMElement $parent)
{
$definitions = $this->container->getDefinitions();
$element->setAttribute($keyAttribute, $key);
}
+ if ($value instanceof ServiceClosureArgument) {
+ $value = $value->getValues()[0];
+ }
if (is_array($value)) {
$element->setAttribute('type', 'collection');
$this->convertParameters($value, $type, $element, 'key');
+ } elseif ($value instanceof TaggedIteratorArgument) {
+ $element->setAttribute('type', 'tagged');
+ $element->setAttribute('tag', $value->getTag());
+ } elseif ($value instanceof IteratorArgument) {
+ $element->setAttribute('type', 'iterator');
+ $this->convertParameters($value->getValues(), $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) {
+ if (ContainerInterface::NULL_ON_INVALID_REFERENCE == $behaviour) {
$element->setAttribute('on-invalid', 'null');
- } elseif ($behaviour == ContainerInterface::IGNORE_ON_INVALID_REFERENCE) {
+ } elseif (ContainerInterface::IGNORE_ON_INVALID_REFERENCE == $behaviour) {
$element->setAttribute('on-invalid', 'ignore');
- }
- if (!$value->isStrict(false)) {
- $element->setAttribute('strict', 'false');
+ } elseif (ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE == $behaviour) {
+ $element->setAttribute('on-invalid', 'ignore_uninitialized');
}
} elseif ($value instanceof Definition) {
$element->setAttribute('type', 'service');
/**
* Escapes arguments.
*
- * @param array $arguments
- *
* @return array
*/
private function escape(array $arguments)