Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-extension / src / Drupal / DrupalExtension / Compiler / EventSubscriberPass.php
1 <?php
2
3 namespace Drupal\DrupalExtension\Compiler;
4
5 use Symfony\Component\DependencyInjection\Reference,
6     Symfony\Component\DependencyInjection\ContainerBuilder,
7     Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
9 /**
10  * Event subscribers pass - registers all available event subscribers.
11  */
12 class EventSubscriberPass implements CompilerPassInterface {
13   /**
14    * Processes container.
15    *
16    * @param ContainerBuilder $container
17    */
18   public function process(ContainerBuilder $container) {
19     if (!$container->hasDefinition('drupal.event_dispatcher')) {
20       return;
21     }
22     $dispatcherDefinition = $container->getDefinition('drupal.event_dispatcher');
23
24     foreach ($container->findTaggedServiceIds('drupal.event_subscriber') as $id => $attributes) {
25       foreach ($attributes as $attribute) {
26         $priority = isset($attribute['priority']) ? intval($attribute['priority']) : 0;
27         $dispatcherDefinition->addMethodCall(
28           'addSubscriber', array(new Reference($id), $priority)
29         );
30       }
31     }
32   }
33 }