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 f06afb9

Browse filesBrowse files
[FrameworkBundle] Fix deprecation when accessing a "container.private" service from the test container
1 parent 3545102 commit f06afb9
Copy full SHA for f06afb9

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+20
-0
lines changed

‎DependencyInjection/Compiler/TestServiceContainerRealRefPass.php

Copy file name to clipboardExpand all lines: DependencyInjection/Compiler/TestServiceContainerRealRefPass.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
@@ -38,6 +39,16 @@ public function process(ContainerBuilder $container)
3839
}
3940
}
4041

42+
foreach ($container->getAliases() as $id => $target) {
43+
while ($container->hasAlias($target = (string) $target)) {
44+
$target = $container->getAlias($target);
45+
}
46+
47+
if ($definitions[$target]->hasTag('container.private')) {
48+
$privateServices[$id] = new ServiceClosureArgument(new Reference($target));
49+
}
50+
}
51+
4152
$privateContainer->replaceArgument(0, $privateServices);
4253
}
4354
}

‎Tests/DependencyInjection/Compiler/TestServiceContainerRefPassesTest.php

Copy file name to clipboardExpand all lines: Tests/DependencyInjection/Compiler/TestServiceContainerRefPassesTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public function testProcess()
4343
->setPublic(true)
4444
->addTag('container.private', ['package' => 'foo/bar', 'version' => '1.42'])
4545
;
46+
$container->register('Test\soon_private_service_decorated')
47+
->setPublic(true)
48+
->addTag('container.private', ['package' => 'foo/bar', 'version' => '1.42'])
49+
;
50+
$container->register('Test\soon_private_service_decorator')
51+
->setDecoratedService('Test\soon_private_service_decorated')
52+
->setArguments(['Test\soon_private_service_decorator.inner']);
4653

4754
$container->register('Test\private_used_shared_service');
4855
$container->register('Test\private_unused_shared_service');
@@ -55,6 +62,8 @@ public function testProcess()
5562
'Test\private_used_shared_service' => new ServiceClosureArgument(new Reference('Test\private_used_shared_service')),
5663
'Test\private_used_non_shared_service' => new ServiceClosureArgument(new Reference('Test\private_used_non_shared_service')),
5764
'Test\soon_private_service' => new ServiceClosureArgument(new Reference('.container.private.Test\soon_private_service')),
65+
'Test\soon_private_service_decorator' => new ServiceClosureArgument(new Reference('.container.private.Test\soon_private_service_decorated')),
66+
'Test\soon_private_service_decorated' => new ServiceClosureArgument(new Reference('.container.private.Test\soon_private_service_decorated')),
5867
];
5968

6069
$privateServices = $container->getDefinition('test.private_services_locator')->getArgument(0);

0 commit comments

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