class RegisterServicesForDestructionPass

Adds services tagged "needs_destruction" to the "kernel_destruct_subscriber" service.

Hierarchy

Expanded class hierarchy of RegisterServicesForDestructionPass

1 file declares its use of RegisterServicesForDestructionPass
CoreBundle.php in drupal/core/lib/Drupal/Core/CoreBundle.php
Definition of Drupal\Core\CoreBundle.

File

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

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class RegisterServicesForDestructionPass implements CompilerPassInterface {

  /**
   * Implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface::process().
   */
  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,
      ));
    }
  }

}

Members