Skip to content

Commit f79ccae

Browse files
Merge branch '3.1'
* 3.1: [travis] Use 7.0 until 7.1 is fixed [DIC] Fix service autowiring inheritance [Serializer] Fix denormalization of arrays [SecurityBundle] Add missing deprecation notice for form_login.intention Verify explicitly that the request IP is a valid IPv4 address [WebProfilerBundle] replaces tabs characters by spaces.
2 parents 5d4f4ff + d1524e5 commit f79ccae

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

Compiler/ResolveDefinitionTemplatesPass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ private function resolveDefinition(ContainerBuilder $container, DefinitionDecora
127127
$def->setFile($parentDef->getFile());
128128
$def->setPublic($parentDef->isPublic());
129129
$def->setLazy($parentDef->isLazy());
130+
$def->setAutowired($parentDef->isAutowired());
130131

131132
// overwrite with values specified in the decorator
132133
$changes = $definition->getChanges();
@@ -151,6 +152,9 @@ private function resolveDefinition(ContainerBuilder $container, DefinitionDecora
151152
if (isset($changes['deprecated'])) {
152153
$def->setDeprecated($definition->isDeprecated(), $definition->getDeprecationMessage('%service_id%'));
153154
}
155+
if (isset($changes['autowire'])) {
156+
$def->setAutowired($definition->isAutowired());
157+
}
154158
if (isset($changes['decorated_service'])) {
155159
$decoratedService = $definition->getDecoratedService();
156160
if (null === $decoratedService) {

DefinitionDecorator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ public function setDeprecated($boolean = true, $template = null)
134134
return parent::setDeprecated($boolean, $template);
135135
}
136136

137+
/**
138+
* {@inheritdoc}
139+
*/
140+
public function setAutowired($autowired)
141+
{
142+
$this->changes['autowire'] = true;
143+
144+
return parent::setAutowired($autowired);
145+
}
146+
137147
/**
138148
* Gets an argument to pass to the service constructor/factory method.
139149
*

Tests/Compiler/ResolveDefinitionTemplatesPassTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,36 @@ public function testSetLazyOnServiceIsParent()
210210
$this->assertTrue($container->getDefinition('child1')->isLazy());
211211
}
212212

213+
public function testSetAutowiredOnServiceHasParent()
214+
{
215+
$container = new ContainerBuilder();
216+
217+
$container->register('parent', 'stdClass');
218+
219+
$container->setDefinition('child1', new DefinitionDecorator('parent'))
220+
->setAutowired(true)
221+
;
222+
223+
$this->process($container);
224+
225+
$this->assertTrue($container->getDefinition('child1')->isAutowired());
226+
}
227+
228+
public function testSetAutowiredOnServiceIsParent()
229+
{
230+
$container = new ContainerBuilder();
231+
232+
$container->register('parent', 'stdClass')
233+
->setAutowired(true)
234+
;
235+
236+
$container->setDefinition('child1', new DefinitionDecorator('parent'));
237+
238+
$this->process($container);
239+
240+
$this->assertTrue($container->getDefinition('child1')->isAutowired());
241+
}
242+
213243
public function testDeepDefinitionsResolving()
214244
{
215245
$container = new ContainerBuilder();

Tests/DefinitionDecoratorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ public function testSetLazy()
6969
$this->assertEquals(array('lazy' => true), $def->getChanges());
7070
}
7171

72+
public function testSetAutowired()
73+
{
74+
$def = new DefinitionDecorator('foo');
75+
76+
$this->assertFalse($def->isAutowired());
77+
$this->assertSame($def, $def->setAutowired(false));
78+
$this->assertFalse($def->isAutowired());
79+
$this->assertEquals(array('autowire' => true), $def->getChanges());
80+
}
81+
7282
public function testSetArgument()
7383
{
7484
$def = new DefinitionDecorator('foo');

0 commit comments

Comments
 (0)