Skip to content

Commit 7fbcd20

Browse files
committed
Merge remote-tracking branch 'origin/2.6' into 2.7
Conflicts: src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php src/Symfony/Component/Validator/Constraints/EmailValidator.php
2 parents cd2e432 + 43d0deb commit 7fbcd20

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

Compiler/ResolveDefinitionTemplatesPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ private function resolveDefinition($id, DefinitionDecorator $definition)
125125
if (isset($changes['lazy'])) {
126126
$def->setLazy($definition->isLazy());
127127
}
128+
if (isset($changes['decorated_service'])) {
129+
$decoratedService = $definition->getDecoratedService();
130+
if (null === $decoratedService) {
131+
$def->setDecoratedService($decoratedService);
132+
} else {
133+
$def->setDecoratedService($decoratedService[0], $decoratedService[1]);
134+
}
135+
}
128136

129137
// merge arguments
130138
foreach ($definition->getArguments() as $k => $v) {

DefinitionDecorator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ public function setLazy($boolean)
170170
return parent::setLazy($boolean);
171171
}
172172

173+
/**
174+
* {@inheritdoc}
175+
*/
176+
public function setDecoratedService($id, $renamedId = null)
177+
{
178+
$this->changes['decorated_service'] = true;
179+
180+
return parent::setDecoratedService($id, $renamedId);
181+
}
182+
173183
/**
174184
* Gets an argument to pass to the service constructor/factory method.
175185
*

Tests/Compiler/ResolveDefinitionTemplatesPassTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,25 @@ public function testProcessDoesNotCopyTags()
117117
$this->assertEquals(array(), $def->getTags());
118118
}
119119

120+
public function testProcessDoesNotCopyDecoratedService()
121+
{
122+
$container = new ContainerBuilder();
123+
124+
$container
125+
->register('parent')
126+
->setDecoratedService('foo')
127+
;
128+
129+
$container
130+
->setDefinition('child', new DefinitionDecorator('parent'))
131+
;
132+
133+
$this->process($container);
134+
135+
$def = $container->getDefinition('child');
136+
$this->assertNull($def->getDecoratedService());
137+
}
138+
120139
public function testProcessHandlesMultipleInheritance()
121140
{
122141
$container = new ContainerBuilder();
@@ -173,6 +192,21 @@ public function testSetLazyOnServiceIsParent()
173192
$this->assertTrue($container->getDefinition('child1')->isLazy());
174193
}
175194

195+
public function testSetDecoratedServiceOnServiceHasParent()
196+
{
197+
$container = new ContainerBuilder();
198+
199+
$container->register('parent', 'stdClass');
200+
201+
$container->setDefinition('child1', new DefinitionDecorator('parent'))
202+
->setDecoratedService('foo', 'foo_inner')
203+
;
204+
205+
$this->process($container);
206+
207+
$this->assertEquals(array('foo', 'foo_inner'), $container->getDefinition('child1')->getDecoratedService());
208+
}
209+
176210
protected function process(ContainerBuilder $container)
177211
{
178212
$pass = new ResolveDefinitionTemplatesPass();

0 commit comments

Comments
 (0)