RouteBuilder.php 918 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<?php

namespace Drupal\Core\Routing;

use Symfony\Component\Routing\RouteCompilerInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\Matcher\Dumper\MatcherDumperInterface;

/**
 * Managing class for rebuilding the router table.
 *
 * Because this class makes use of the modules system, it cannot currently
 * be unit tested.
 */
class RouteBuilder {

  protected $dumper;

  public function __construct(MatcherDumperInterface $dumper) {
    $this->dumper = $dumper;
  }

  public function rebuild() {
    // We need to manually call each module so that we can know which module
    // a given item came from.

    foreach (module_implements('route_info') as $module) {
      $routes = call_user_func($module . '_route_info');
      drupal_alter('router_info', $routes, $module);
      $this->dumper->addRoutes($routes);
      $this->dumper->dump(array('route_set' => $module));
    }
  }

}