Move router rebuilding into an object so we can break it up more easily.
parent
404e74e187
commit
f6bf963097
|
@ -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 @@ class CoreBundle extends Bundle
|
|||
|
||||
$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.
|
||||
|
|
|
@ -0,0 +1,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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue