public function RegisterServicesForDestructionPass::process

Implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface::process().

Overrides CompilerPassInterface::process

File

drupal/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php, line 22
Contains \Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass.

Class

RegisterServicesForDestructionPass
Adds services tagged "needs_destruction" to the "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', array(
      $id,
    ));
  }
}