function RegisterServicesForDestructionPass::process

File

core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php, line 20

Class

RegisterServicesForDestructionPass
Adds services with specific tags to "kernel_destruct_subscriber" service.

Namespace

Drupal\Core\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  if (!$container->hasDefinition('kernel_destruct_subscriber')) {
    return;
  }
  $definition = $container->getDefinition('kernel_destruct_subscriber');
  $services = $container->findTaggedServiceIds('needs_destruction');
  foreach ($services as $id => $attributes) {
    $definition->addMethodCall('registerService', [
      $id,
    ]);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.