Skip to content

Commit 9e2fb7a

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

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
@@ -936,7 +936,7 @@ public function createService(Definition $definition, $id, $tryProxy = true)
936936
$this->callMethod($service, $call);
937937
}
938938

939-
$properties = $this->resolveServices($parameterBag->resolveValue($definition->getProperties()));
939+
$properties = $this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getProperties())));
940940
foreach ($properties as $name => $value) {
941941
$service->$name = $value;
942942
}
@@ -1134,7 +1134,7 @@ private function callMethod($service, $call)
11341134
}
11351135
}
11361136

1137-
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1])));
1137+
call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->unescapeValue($this->getParameterBag()->resolveValue($call[1]))));
11381138
}
11391139

11401140
/**

Tests/ContainerBuilderTest.php

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

358+
public function testCreateServiceMethodCallsWithEscapedParam()
359+
{
360+
$builder = new ContainerBuilder();
361+
$builder->register('bar', 'stdClass');
362+
$builder->register('foo1', 'FooClass')->addMethodCall('setBar', array(array('%%unescape_it%%')));
363+
$builder->setParameter('value', 'bar');
364+
$this->assertEquals(array('%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the method calls arguments');
365+
}
366+
367+
public function testCreateServiceProperties()
368+
{
369+
$builder = new ContainerBuilder();
370+
$builder->register('bar', 'stdClass');
371+
$builder->register('foo1', 'FooClass')->setProperty('bar', array('%value%', new Reference('bar'), '%%unescape_it%%'));
372+
$builder->setParameter('value', 'bar');
373+
$this->assertEquals(array('bar', $builder->get('bar'), '%unescape_it%'), $builder->get('foo1')->bar, '->createService() replaces the values in the properties');
374+
}
375+
358376
public function testCreateServiceConfigurator()
359377
{
360378
$builder = new ContainerBuilder();

0 commit comments

Comments
 (0)