3 namespace Drupal\Core\DependencyInjection\Compiler;
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9 * Adds services tagged "needs_destruction" to the "kernel_destruct_subscriber"
12 * @see \Drupal\Core\DestructableInterface
14 class RegisterServicesForDestructionPass implements CompilerPassInterface {
19 public function process(ContainerBuilder $container) {
20 if (!$container->hasDefinition('kernel_destruct_subscriber')) {
24 $definition = $container->getDefinition('kernel_destruct_subscriber');
25 $services = $container->findTaggedServiceIds('needs_destruction');
26 foreach ($services as $id => $attributes) {
27 $definition->addMethodCall('registerService', [$id]);