RegisterServicesForDestructionPass.php

Same filename and directory in other branches
  1. 9 core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
  2. 8.9.x core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
  3. 10 core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php

Namespace

Drupal\Core\DependencyInjection\Compiler

File

core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php

View source
<?php

namespace Drupal\Core\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
 * Adds services to the "kernel.destructable_services" container parameter.
 *
 * Only services tagged with "needs_destruction" are added.
 *
 * @see \Drupal\Core\DestructableInterface
 */
class RegisterServicesForDestructionPass implements CompilerPassInterface {
    
    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container) : void {
        $services = $container->findTaggedServiceIds('needs_destruction');
        $container->setParameter('kernel.destructable_services', array_keys($services));
    }

}

Classes

Title Deprecated Summary
RegisterServicesForDestructionPass Adds services to the "kernel.destructable_services" container parameter.

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