You are here

public function RegisterServicesForDestructionPass::process in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php \Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass::process()

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

Overrides CompilerPassInterface::process

File

lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php, line 24
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,
    ));
  }
}