Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / DependencyInjection / Compiler / RegisterServicesForDestructionPass.php
1 <?php
2
3 namespace Drupal\Core\DependencyInjection\Compiler;
4
5 use Symfony\Component\DependencyInjection\ContainerBuilder;
6 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
8 /**
9  * Adds services tagged "needs_destruction" to the "kernel_destruct_subscriber"
10  * service.
11  *
12  * @see \Drupal\Core\DestructableInterface
13  */
14 class RegisterServicesForDestructionPass implements CompilerPassInterface {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function process(ContainerBuilder $container) {
20     if (!$container->hasDefinition('kernel_destruct_subscriber')) {
21       return;
22     }
23
24     $definition = $container->getDefinition('kernel_destruct_subscriber');
25     $services = $container->findTaggedServiceIds('needs_destruction');
26     foreach ($services as $id => $attributes) {
27       $definition->addMethodCall('registerService', [$id]);
28     }
29   }
30
31 }