5 * Contains \Drupal\drupalmoduleupgrader\Converter\Routing\RouterBase.
8 namespace Drupal\drupalmoduleupgrader\Routing;
10 use Doctrine\Common\Collections\ArrayCollection;
11 use Symfony\Component\EventDispatcher\EventDispatcher;
14 * Base class for RouterInterface implementations.
16 class RouterBase extends ArrayCollection implements RouterInterface {
19 * @var \Symfony\Component\EventDispatcher\EventDispatcher
21 protected $dispatcher;
24 * Constructs a RouterBase.
26 public function __construct(array $elements = []) {
27 parent::__construct($elements);
28 $this->dispatcher = new EventDispatcher();
34 public function addRoute(RouteWrapperInterface $route) {
35 $this->set($route->getIdentifier(), $route);
36 $this->dispatcher->addListener('router.built', [ $route, 'onRouterBuilt' ]);
42 public function finalize() {
43 $this->dispatcher->dispatch('router.built', new RouterBuiltEvent($this));