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

Appearance settings

Commit 219575f

Browse filesBrowse files
committed
Merge branch '4.4' into 5.4
* 4.4: [DependencyInjection] Fix "proxy" tag: resolve its parameters and pass it to child definitions
2 parents f79ed9a + dffd4e5 commit 219575f
Copy full SHA for 219575f

File tree

Expand file treeCollapse file tree

4 files changed

+50
-0
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+50
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ private function doResolveDefinition(ChildDefinition $definition): Definition
193193
// and it's not legal on an instanceof
194194
$def->setAutoconfigured($definition->isAutoconfigured());
195195

196+
if (!$def->hasTag('proxy')) {
197+
foreach ($parentDef->getTag('proxy') as $v) {
198+
$def->addTag('proxy', $v);
199+
}
200+
}
201+
196202
return $def;
197203
}
198204
}

‎src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ protected function processValue($value, bool $isRoot = false)
8585
if (isset($changes['file'])) {
8686
$value->setFile($this->bag->resolveValue($value->getFile()));
8787
}
88+
$tags = $value->getTags();
89+
if (isset($tags['proxy'])) {
90+
$tags['proxy'] = $this->bag->resolveValue($tags['proxy']);
91+
$value->setTags($tags);
92+
}
8893
}
8994

9095
$value = parent::processValue($value, $isRoot);

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,31 @@ public function testProcessDoesNotCopyTags()
121121
$this->assertEquals([], $def->getTags());
122122
}
123123

124+
public function testProcessCopiesTagsProxy()
125+
{
126+
$container = new ContainerBuilder();
127+
128+
$container
129+
->register('parent')
130+
->addTag('proxy', ['a' => 'b'])
131+
;
132+
133+
$container
134+
->setDefinition('child1', new ChildDefinition('parent'))
135+
;
136+
$container
137+
->setDefinition('child2', (new ChildDefinition('parent'))->addTag('proxy', ['c' => 'd']))
138+
;
139+
140+
$this->process($container);
141+
142+
$def = $container->getDefinition('child1');
143+
$this->assertSame(['proxy' => [['a' => 'b']]], $def->getTags());
144+
145+
$def = $container->getDefinition('child2');
146+
$this->assertSame(['proxy' => [['c' => 'd']]], $def->getTags());
147+
}
148+
124149
public function testProcessDoesNotCopyDecoratedService()
125150
{
126151
$container = new ContainerBuilder();

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ public function testParameterNotFoundExceptionsIsNotThrown()
9797
$this->assertCount(1, $definition->getErrors());
9898
}
9999

100+
public function testOnlyProxyTagIsResolved()
101+
{
102+
$containerBuilder = new ContainerBuilder();
103+
$containerBuilder->setParameter('a_param', 'here_you_go');
104+
$definition = $containerBuilder->register('def');
105+
$definition->addTag('foo', ['bar' => '%a_param%']);
106+
$definition->addTag('proxy', ['interface' => '%a_param%']);
107+
108+
$pass = new ResolveParameterPlaceHoldersPass(true, false);
109+
$pass->process($containerBuilder);
110+
111+
$this->assertSame(['foo' => [['bar' => '%a_param%']], 'proxy' => [['interface' => 'here_you_go']]], $definition->getTags());
112+
}
113+
100114
private function createContainerBuilder(): ContainerBuilder
101115
{
102116
$containerBuilder = new ContainerBuilder();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.