Security update for permissions_by_term
[yaffs-website] / vendor / drupal / drupal-extension / src / Drupal / DrupalExtension / Compiler / EventSubscriberPass.php
diff --git a/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Compiler/EventSubscriberPass.php b/vendor/drupal/drupal-extension/src/Drupal/DrupalExtension/Compiler/EventSubscriberPass.php
new file mode 100644 (file)
index 0000000..45daa1d
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\DrupalExtension\Compiler;
+
+use Symfony\Component\DependencyInjection\Reference,
+    Symfony\Component\DependencyInjection\ContainerBuilder,
+    Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
+
+/**
+ * Event subscribers pass - registers all available event subscribers.
+ */
+class EventSubscriberPass implements CompilerPassInterface {
+  /**
+   * Processes container.
+   *
+   * @param ContainerBuilder $container
+   */
+  public function process(ContainerBuilder $container) {
+    if (!$container->hasDefinition('drupal.event_dispatcher')) {
+      return;
+    }
+    $dispatcherDefinition = $container->getDefinition('drupal.event_dispatcher');
+
+    foreach ($container->findTaggedServiceIds('drupal.event_subscriber') as $id => $attributes) {
+      foreach ($attributes as $attribute) {
+        $priority = isset($attribute['priority']) ? intval($attribute['priority']) : 0;
+        $dispatcherDefinition->addMethodCall(
+          'addSubscriber', array(new Reference($id), $priority)
+        );
+      }
+    }
+  }
+}