RegisterServicesForDestructionPass.php in Drupal 8
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;
class RegisterServicesForDestructionPass implements CompilerPassInterface {
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,
]);
}
}
}