drupalmoduleupgrader-8.x-1.5/src/Routing/RouterBase.php

src/Routing/RouterBase.php
<?php

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(new RouterBuiltEvent($this), 'router.built');
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc