Skip to content

Commit 158a7b3

Browse files
committed
[DI] move RegisterServiceSubscribersPass before DecoratorServicePass
1 parent 8fa0dd6 commit 158a7b3

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Compiler/PassConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public function __construct()
5151
$this->optimizationPasses = array(array(
5252
new ResolveChildDefinitionsPass(),
5353
new ServiceLocatorTagPass(),
54+
new RegisterServiceSubscribersPass(),
5455
new DecoratorServicePass(),
5556
new ResolveParameterPlaceHoldersPass(false),
5657
new ResolveFactoryClassPass(),
5758
new FactoryReturnTypePass($resolveClassPass),
5859
new CheckDefinitionValidityPass(),
59-
new RegisterServiceSubscribersPass(),
6060
new ResolveNamedArgumentsPass(),
6161
new AutowireRequiredMethodsPass(),
6262
new ResolveBindingsPass(),

Tests/Compiler/IntegrationTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
1818
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1919
use Symfony\Component\DependencyInjection\Reference;
20+
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
2021

2122
/**
2223
* This class tests the integration of the different compiler passes.
@@ -117,6 +118,21 @@ public function testProcessInlinesWhenThereAreMultipleReferencesButFromTheSameDe
117118
$this->assertFalse($container->hasDefinition('c'), 'Service C was not inlined.');
118119
}
119120

121+
public function testCanDecorateServiceSubscriber()
122+
{
123+
$container = new ContainerBuilder();
124+
$container->register(ServiceSubscriberStub::class)
125+
->addTag('container.service_subscriber')
126+
->setPublic(true);
127+
128+
$container->register(DecoratedServiceSubscriber::class)
129+
->setDecoratedService(ServiceSubscriberStub::class);
130+
131+
$container->compile();
132+
133+
$this->assertInstanceOf(DecoratedServiceSubscriber::class, $container->get(ServiceSubscriberStub::class));
134+
}
135+
120136
/**
121137
* @dataProvider getYamlCompileTests
122138
*/
@@ -207,6 +223,18 @@ public function getYamlCompileTests()
207223
}
208224
}
209225

226+
class ServiceSubscriberStub implements ServiceSubscriberInterface
227+
{
228+
public static function getSubscribedServices()
229+
{
230+
return array();
231+
}
232+
}
233+
234+
class DecoratedServiceSubscriber
235+
{
236+
}
237+
210238
class IntegrationTestStub extends IntegrationTestStubParent
211239
{
212240
}

0 commit comments

Comments
 (0)