Skip to content

Commit 628b58c

Browse files
Merge branch '2.3' into 2.7
* 2.3: Sent out a status text for unknown HTTP headers. [DependencyInjection] Unescape parameters for all types of injection
2 parents 9b385f6 + d3c6bca commit 628b58c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ public function createService(Definition $definition, $id, $tryProxy = true)
901901
$this->callMethod($service, $call);
902902
}
903903

904-
$properties = $this->resolveServices($parameterBag->resolveValue($definition->getProperties()));
904+
$properties = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getProperties())));
905905
foreach ($properties as $name => $value) {
906906
$service->$name = $value;
907907
}
@@ -1088,7 +1088,7 @@ private function callMethod($service, $call)
10881088
}
10891089
}
10901090

1091-
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1])));
1091+
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->unescapeValue($this->getParameterBag()->resolveValue($call[1]))));
10921092
}
10931093

10941094
/**

Tests/ContainerBuilderTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,24 @@ public function testCreateServiceMethodCalls()
320320
$this->assertEquals(array('bar', $builder->get('bar')), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments');
321321
}
322322

323+
public function testCreateServiceMethodCallsWithEscapedParam()
324+
{
325+
$builder = new ContainerBuilder();
326+
$builder->register('bar', 'stdClass');
327+
$builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%%unescape_it%%')));
328+
$builder->setParameter('value', 'bar');
329+
$this->assertEquals(array('%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments');
330+
}
331+
332+
public function testCreateServiceProperties()
333+
{
334+
$builder = new ContainerBuilder();
335+
$builder->register('bar', 'stdClass');
336+
$builder->register('foo1', 'FooClass')->setProperty('bar', array('%value%', new Reference('bar'), '%%unescape_it%%'));
337+
$builder->setParameter('value', 'bar');
338+
$this->assertEquals(array('bar', $builder->get('bar'), '%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the properties');
339+
}
340+
323341
public function testCreateServiceConfigurator()
324342
{
325343
$builder = new ContainerBuilder();

0 commit comments

Comments
 (0)