You are here

class RouterBase in Drupal 7 to 8/9 Module Upgrader 8

Base class for RouterInterface implementations.

Hierarchy

  • class \Drupal\drupalmoduleupgrader\Routing\RouterBase extends \Doctrine\Common\Collections\ArrayCollection implements RouterInterface

Expanded class hierarchy of RouterBase

3 files declare their use of RouterBase
HookMenu.php in src/Routing/HookMenu.php
Router.php in src/Routing/Drupal7/Router.php
RouterBaseTest.php in tests/src/Unit/Routing/RouterBaseTest.php

File

src/Routing/RouterBase.php, line 11

Namespace

Drupal\drupalmoduleupgrader\Routing
View source
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));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouterBase::$dispatcher protected property
RouterBase::addRoute public function Adds a wrapped route definition to this router. Overrides RouterInterface::addRoute
RouterBase::finalize public function Completes the 'build' of this router, dispatching the 'router.built' event to all added routes. Overrides RouterInterface::finalize
RouterBase::__construct public function Constructs a RouterBase.