Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Routing / RouterBase.php
diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Routing/RouterBase.php b/web/modules/contrib/drupalmoduleupgrader/src/Routing/RouterBase.php
new file mode 100644 (file)
index 0000000..ac057dc
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\drupalmoduleupgrader\Converter\Routing\RouterBase.
+ */
+
+namespace Drupal\drupalmoduleupgrader\Routing;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+
+/**
+ * Base class for RouterInterface implementations.
+ */
+class RouterBase extends ArrayCollection implements RouterInterface {
+
+  /**
+   * @var \Symfony\Component\EventDispatcher\EventDispatcher
+   */
+  protected $dispatcher;
+
+  /**
+   * Constructs a RouterBase.
+   */
+  public function __construct(array $elements = []) {
+    parent::__construct($elements);
+    $this->dispatcher = new EventDispatcher();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function addRoute(RouteWrapperInterface $route) {
+    $this->set($route->getIdentifier(), $route);
+    $this->dispatcher->addListener('router.built', [ $route, 'onRouterBuilt' ]);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function finalize() {
+    $this->dispatcher->dispatch('router.built', new RouterBuiltEvent($this));
+  }
+
+}