Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7f100e

Browse files
NicofumaTristan Darricau
authored and
Tristan Darricau
committed
[DependencyInjection] Unescape parameters for all types of injection
1 parent613910b commitc7f100e

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php‎

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

898-
$properties =$this->resolveServices($parameterBag->resolveValue($definition->getProperties()));
898+
$properties =$this->resolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getProperties())));
899899
foreach ($propertiesas$name =>$value) {
900900
$service->$name =$value;
901901
}
@@ -1052,7 +1052,7 @@ private function callMethod($service, $call)
10521052
}
10531053
}
10541054

1055-
call_user_func_array(array($service,$call[0]),$this->resolveServices($this->getParameterBag()->resolveValue($call[1])));
1055+
call_user_func_array(array($service,$call[0]),$this->resolveServices($this->getParameterBag()->unescapeValue($this->getParameterBag()->resolveValue($call[1]))));
10561056
}
10571057

10581058
/**

‎src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php‎

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

372+
/**
373+
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
374+
*/
375+
publicfunctiontestCreateServiceMethodCallsWithEscapedParam()
376+
{
377+
$builder =newContainerBuilder();
378+
$builder->register('bar','stdClass');
379+
$builder->register('foo1','FooClass')->addMethodCall('setBar',array(array('%%unescape_it%%')));
380+
$builder->setParameter('value','bar');
381+
$this->assertEquals(array('%unescape_it%'),$builder->get('foo1')->bar,'->createService() replaces the values in the method calls arguments');
382+
}
383+
384+
/**
385+
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
386+
*/
387+
publicfunctiontestCreateServiceProperties()
388+
{
389+
$builder =newContainerBuilder();
390+
$builder->register('bar','stdClass');
391+
$builder->register('foo1','FooClass')->setProperty('bar',array('%value%',newReference('bar'),'%%unescape_it%%'));
392+
$builder->setParameter('value','bar');
393+
$this->assertEquals(array('bar',$builder->get('bar'),'%unescape_it%'),$builder->get('foo1')->bar,'->createService() replaces the values in the properties');
394+
}
395+
372396
/**
373397
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
374398
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp