Skip to content

Commit d272009

Browse files
committed
A DI tag for resettable services.
1 parent 6dcf70b commit d272009

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

FrameworkBundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
3434
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
3535
use Symfony\Component\HttpKernel\DependencyInjection\RemoveEmptyControllerArgumentLocatorsPass;
36+
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
3637
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
3738
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
3839
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;
@@ -117,6 +118,7 @@ public function build(ContainerBuilder $container)
117118
$container->addCompilerPass(new CachePoolPrunerPass(), PassConfig::TYPE_AFTER_REMOVING);
118119
$this->addCompilerPassIfExists($container, FormPass::class);
119120
$container->addCompilerPass(new WorkflowGuardListenerPass());
121+
$container->addCompilerPass(new ResettableServicePass());
120122

121123
if ($container->getParameter('kernel.debug')) {
122124
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);

Resources/config/services.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,11 @@
7474
<service id="Symfony\Component\Config\Resource\SelfCheckingResourceChecker">
7575
<tag name="config_cache.resource_checker" priority="-990" />
7676
</service>
77+
78+
<service id="Symfony\Component\HttpKernel\EventListener\ServiceResetListener">
79+
<argument /> <!-- ResettableServicePass will inject an iterator of initialized services here ($serviceId => $serviceInstance) -->
80+
<argument type="collection" /> <!-- ResettableServicePass will inject an array of reset methods here ($serviceId => $method) -->
81+
<tag name="kernel.event_subscriber" />
82+
</service>
7783
</services>
7884
</container>

0 commit comments

Comments
 (0)