Commit f6bf9630 authored by Crell's avatar Crell Committed by effulgentsia

Move router rebuilding into an object so we can break it up more easily.

parent 404e74e1
......@@ -6830,7 +6830,7 @@ function drupal_flush_all_caches() {
// Rebuild the menu router based on all rebuilt data.
// Important: This rebuild must happen last, so the menu router is guaranteed
// to be based on up to date information.
router_rebuild();
drupal_container()->get('router.builder')->rebuild();
menu_router_rebuild();
// Re-initialize the maintenance theme, if the current request attempted to
......@@ -6842,22 +6842,6 @@ function drupal_flush_all_caches() {
}
}
function router_rebuild() {
// We need to manually call each module so that we can know which module
// a given item came from.
$dumper = drupal_container()->get('router.dumper', Container::NULL_ON_INVALID_REFERENCE);
if ($dumper) {
foreach (module_implements('route_info') as $module) {
$routes = call_user_func($module . '_route_info');
drupal_alter('router_info', $routes, $module);
$dumper->addRoutes($routes);
$dumper->dump(array('route_set' => $module));
}
}
}
/**
* Changes the dummy query string added to all CSS and JavaScript files.
*
......
......@@ -58,6 +58,8 @@ public function build(ContainerBuilder $container) {
$container->register('router.dumper', '\Drupal\Core\Routing\MatcherDumper')
->addArgument(new Reference('database'));
$container->register('router.builder', 'Drupal\Core\Routing\RouteBuilder')
->addArgument(new Reference('router.dumper'));
// @todo Replace below lines with the commented out block below it when it's
// performant to do so: http://drupal.org/node/1706064.
......
<?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));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment