diff --git a/core/core.services.yml b/core/core.services.yml index d723cd8ea9c7dd4a784583e1208cefceda84be36..2b81197e13f643370c3b84e8d6b0db09636c9a8f 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -343,7 +343,7 @@ services: arguments: ['@entity.manager', '@string_translation'] theme_handler: class: Drupal\Core\Extension\ThemeHandler - arguments: ['@app.root', '@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder_indicator'] + arguments: ['@app.root', '@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder'] entity.manager: class: Drupal\Core\Entity\EntityManager arguments: ['@container.namespaces', '@module_handler', '@cache.discovery', '@language_manager', '@string_translation', '@class_resolver', '@typed_data_manager', '@entity.definitions.installed', '@event_dispatcher'] @@ -553,7 +553,7 @@ services: arguments: ['@current_route_match'] router.route_provider: class: Drupal\Core\Routing\RouteProvider - arguments: ['@database', '@router.builder', '@state', '@path.current'] + arguments: ['@database', '@state', '@path.current'] tags: - { name: event_subscriber } - { name: backend_overridable } @@ -635,17 +635,11 @@ services: arguments: ['@database', '@state'] tags: - { name: backend_overridable } - router.builder_indicator: - class: Drupal\Core\Routing\RouteBuilderIndicator - arguments: ['@state'] router.builder: class: Drupal\Core\Routing\RouteBuilder - arguments: ['@router.dumper', '@lock', '@event_dispatcher', '@module_handler', '@controller_resolver', '@access_manager.check_provider', '@router.builder_indicator'] - router.rebuild_subscriber: - class: Drupal\Core\EventSubscriber\RouterRebuildSubscriber - arguments: ['@router.builder'] + arguments: ['@router.dumper', '@lock', '@event_dispatcher', '@module_handler', '@controller_resolver', '@access_manager.check_provider'] tags: - - { name: event_subscriber } + - { name: needs_destruction } menu.rebuild_subscriber: class: Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber arguments: ['@lock', '@plugin.manager.menu.link'] diff --git a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php index 57cc61897965e8801ba3d16b25f0acc6b815eba9..de441138b59757c69873f325a9845eed36ccccd0 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php @@ -19,11 +19,6 @@ */ class MenuRouterRebuildSubscriber implements EventSubscriberInterface { - /** - * @var \Drupal\Core\Routing\RouteBuilderInterface - */ - protected $routeBuilder; - /** * @var \Drupal\Core\Lock\LockBackendInterface */ diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index dba7a94de5dc7b632abc55f7c4470947cce420e5..412a7b31aef5fef72bcae9fac0c1e800d01b2d4d 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -220,9 +220,8 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // Now install the module's schema if necessary. drupal_install_schema($module); - // Clear plugin manager caches and flag router to rebuild if requested. + // Clear plugin manager caches. \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); // Set the schema version to the number of the last update provided by // the module, or the minimum core schema version. @@ -296,6 +295,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // If any modules were newly installed, invoke hook_modules_installed(). if (!empty($modules_installed)) { + \Drupal::service('router.builder')->rebuild(); $this->moduleHandler->invokeAll('modules_installed', array($modules_installed)); } @@ -417,9 +417,8 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // its statically cached list. drupal_static_reset('system_rebuild_module_data'); - // Clear plugin manager caches and flag router to rebuild if requested. + // Clear plugin manager caches. \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); // Update the kernel to exclude the uninstalled modules. $this->updateKernel($module_filenames); @@ -438,6 +437,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { $schema_store = \Drupal::keyValue('system.schema'); $schema_store->delete($module); } + \Drupal::service('router.builder')->rebuild(); drupal_get_installed_schema_version(NULL, TRUE); // Let other modules react. diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 0513eb512a2c90f1c6dc658812b2bb715fb7e696..dcb1fe3a2f3e7b99e97690a9932e030e1dd7a8b3 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -14,7 +14,7 @@ use Drupal\Core\Config\ConfigInstallerInterface; use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Config\PreExistingConfigException; -use Drupal\Core\Routing\RouteBuilderIndicatorInterface; +use Drupal\Core\Routing\RouteBuilderInterface; use Drupal\Core\State\StateInterface; use Psr\Log\LoggerInterface; @@ -88,11 +88,11 @@ class ThemeHandler implements ThemeHandlerInterface { protected $logger; /** - * The route builder indicator to rebuild the routes if a theme is installed. + * The route builder to rebuild the routes if a theme is installed. * - * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface + * @var \Drupal\Core\Routing\RouteBuilderInterface */ - protected $routeBuilderIndicator; + protected $routeBuilder; /** * An extension discovery instance. @@ -145,13 +145,13 @@ class ThemeHandler implements ThemeHandlerInterface { * database. * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager * The config manager used to uninstall a theme. - * @param \Drupal\Core\Routing\RouteBuilderIndicatorInterface $route_builder_indicator - * (optional) The route builder indicator service to rebuild the routes if a - * theme is installed. + * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder + * (optional) The route builder service to rebuild the routes if a theme is + * installed. * @param \Drupal\Core\Extension\ExtensionDiscovery $extension_discovery * (optional) A extension discovery instance (for unit tests). */ - public function __construct($root, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, StateInterface $state, InfoParserInterface $info_parser,LoggerInterface $logger, AssetCollectionOptimizerInterface $css_collection_optimizer = NULL, ConfigInstallerInterface $config_installer = NULL, ConfigManagerInterface $config_manager = NULL, RouteBuilderIndicatorInterface $route_builder_indicator = NULL, ExtensionDiscovery $extension_discovery = NULL) { + public function __construct($root, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, StateInterface $state, InfoParserInterface $info_parser,LoggerInterface $logger, AssetCollectionOptimizerInterface $css_collection_optimizer = NULL, ConfigInstallerInterface $config_installer = NULL, ConfigManagerInterface $config_manager = NULL, RouteBuilderInterface $route_builder = NULL, ExtensionDiscovery $extension_discovery = NULL) { $this->root = $root; $this->configFactory = $config_factory; $this->moduleHandler = $module_handler; @@ -161,7 +161,7 @@ public function __construct($root, ConfigFactoryInterface $config_factory, Modul $this->cssCollectionOptimizer = $css_collection_optimizer; $this->configInstaller = $config_installer; $this->configManager = $config_manager; - $this->routeBuilderIndicator = $route_builder_indicator; + $this->routeBuilder = $route_builder; $this->extensionDiscovery = $extension_discovery; } @@ -624,8 +624,8 @@ protected function getExtensionDiscovery() { * Resets some other systems like rebuilding the route information or caches. */ protected function resetSystem() { - if ($this->routeBuilderIndicator) { - $this->routeBuilderIndicator->setRebuildNeeded(); + if ($this->routeBuilder) { + $this->routeBuilder->setRebuildNeeded(); } $this->systemListReset(); diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index 997c6db0d763b4e477ceb55dc16575d5f827b6eb..2ef5de1dd2335c8fe270ce12ff9f940993d3ba96 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -201,9 +201,6 @@ public function getLocalTasksForRoute($route_name) { $children = $cache->data['children']; } else { - // Maybe some code asked to rebuild the routes, so rebuild the router - // as we rely on having proper existing routes in dynamic local tasks. - $this->routeBuilder->rebuildIfNeeded(); $definitions = $this->getDefinitions(); // We build the hierarchy by finding all tabs that should // appear on the current route. diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index 433abec1579397f969fd4630eadb3e1caaf4959a..db516af1bbe5c8ff9f64c9f27a972b0e17a55019 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -12,6 +12,7 @@ use Drupal\Core\Controller\ControllerResolverInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Lock\LockBackendInterface; +use Drupal\Core\DestructableInterface; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\RouteCollection; @@ -20,7 +21,7 @@ /** * Managing class for rebuilding the router table. */ -class RouteBuilder implements RouteBuilderInterface { +class RouteBuilder implements RouteBuilderInterface, DestructableInterface { /** * The dumper to which we should send collected routes. @@ -57,13 +58,6 @@ class RouteBuilder implements RouteBuilderInterface { */ protected $moduleHandler; - /** - * The route builder indicator. - * - * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface - */ - protected $routeBuilderIndicator; - /** * The controller resolver. * @@ -79,12 +73,19 @@ class RouteBuilder implements RouteBuilderInterface { protected $routeCollection; /** - * Flag that indiciates if we are currently rebuilding the routes. + * Flag that indicates if we are currently rebuilding the routes. * * @var bool */ protected $building = FALSE; + /** + * Flag that indicates if we should rebuild at the end of the request. + * + * @var bool + */ + protected $rebuildNeeded = FALSE; + /** * The check provider. * @@ -107,19 +108,23 @@ class RouteBuilder implements RouteBuilderInterface { * The controller resolver. * @param \Drupal\Core\Access\CheckProviderInterface $check_provider * The check provider. - * @param \Drupal\Core\Routing\RouteBuilderIndicatorInterface $route_build_indicator - * The route build indicator. */ - public function __construct(MatcherDumperInterface $dumper, LockBackendInterface $lock, EventDispatcherInterface $dispatcher, ModuleHandlerInterface $module_handler, ControllerResolverInterface $controller_resolver, CheckProviderInterface $check_provider, RouteBuilderIndicatorInterface $route_build_indicator = NULL) { + public function __construct(MatcherDumperInterface $dumper, LockBackendInterface $lock, EventDispatcherInterface $dispatcher, ModuleHandlerInterface $module_handler, ControllerResolverInterface $controller_resolver, CheckProviderInterface $check_provider) { $this->dumper = $dumper; $this->lock = $lock; $this->dispatcher = $dispatcher; $this->moduleHandler = $module_handler; $this->controllerResolver = $controller_resolver; - $this->routeBuilderIndicator = $route_build_indicator; $this->checkProvider = $check_provider; } + /** + * {@inheritdoc} + */ + public function setRebuildNeeded() { + $this->rebuildNeeded = TRUE; + } + /** * {@inheritdoc} */ @@ -139,7 +144,6 @@ public function rebuild() { $this->building = TRUE; $collection = new RouteCollection(); - $this->routeCollection = $collection; foreach ($this->getRouteDefinitions() as $routes) { // The top-level 'routes_callback' is a list of methods in controller // syntax, see \Drupal\Core\Controller\ControllerResolver. These methods @@ -176,7 +180,6 @@ public function rebuild() { $route = new Route($route_info['path'], $route_info['defaults'], $route_info['requirements'], $route_info['options']); $collection->add($name, $route); } - } // DYNAMIC is supposed to be used to add new routes based upon all the @@ -193,12 +196,11 @@ public function rebuild() { $this->dumper->addRoutes($collection); $this->dumper->dump(); - $this->routeBuilderIndicator->setRebuildDone(); $this->lock->release('router_rebuild'); $this->dispatcher->dispatch(RoutingEvents::FINISHED, new Event()); $this->building = FALSE; - $this->routeCollection = NULL; + $this->rebuildNeeded = FALSE; return TRUE; } @@ -207,7 +209,7 @@ public function rebuild() { * {@inheritdoc} */ public function rebuildIfNeeded() { - if ($this->routeBuilderIndicator->isRebuildNeeded()) { + if ($this->rebuildNeeded) { return $this->rebuild(); } return FALSE; @@ -216,8 +218,11 @@ public function rebuildIfNeeded() { /** * {@inheritdoc} */ - public function setRebuildNeeded() { - $this->routeBuilderIndicator->setRebuildNeeded(); + public function destruct() { + // Rebuild routes only once at the end of the request lifecycle to not + // trigger multiple rebuilds and also make the page more responsive for the + // user. + $this->rebuildIfNeeded(); } /** diff --git a/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php b/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php deleted file mode 100644 index 5f0612082293862e8c32391cc3f5cd9c626444af..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\Core\Routing\RouteBuilderIndicator. - */ - -namespace Drupal\Core\Routing; - -use Drupal\Core\State\StateInterface; -use Symfony\Component\DependencyInjection\ContainerAware; - -/** - * A simple service to be used instead of the route builder. - * - * The route builder service is required by quite a few other services, - * however it has a lot of dependencies. Use this service to ensure that the - * router is rebuilt. - */ -class RouteBuilderIndicator implements RouteBuilderIndicatorInterface { - - /** - * @var \Drupal\Core\State\StateInterface - */ - protected $state; - - /** - * @param \Drupal\Core\State\StateInterface $state - */ - public function __construct(StateInterface $state) { - $this->state = $state; - } - - /** - * {@inheritdoc} - */ - public function setRebuildNeeded() { - $this->state->set(static::REBUILD_NEEDED, TRUE); - } - - /** - * {@inheritdoc} - */ - public function isRebuildNeeded() { - return $this->state->get(static::REBUILD_NEEDED, FALSE); - } - - /** - * {@inheritdoc} - */ - public function setRebuildDone() { - $this->state->set(static::REBUILD_NEEDED, FALSE); - } - -} diff --git a/core/lib/Drupal/Core/Routing/RouteBuilderIndicatorInterface.php b/core/lib/Drupal/Core/Routing/RouteBuilderIndicatorInterface.php deleted file mode 100644 index 68ce5b800fe6ab6db00ce8655e505b42e59335d5..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Routing/RouteBuilderIndicatorInterface.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -/** - * @file - * Definition of Drupal\Core\Routing\RouteBuilderIndicatorInterface. - */ - -namespace Drupal\Core\Routing; - -interface RouteBuilderIndicatorInterface { - - /** - * The state key to use. - */ - const REBUILD_NEEDED = 'router_rebuild_needed'; - - /** - * Sets the router to be rebuilt next time the kernel is terminated. - * - * @see \Drupal\Core\EventSubscriber\RouterRebuildSubscriber::onKernelTerminate() - * @see \Drupal\Core\Routing\RouteBuilderInterface::rebuildIfNeeded() - * - */ - public function setRebuildNeeded(); - - /** - * Sets the router rebuild indicator to FALSE. - */ - public function setRebuildDone(); - - /** - * Checks if the router needs to be rebuilt. - * - * @return bool - * TRUE if the router needs to be rebuilt, FALSE if not. - */ - public function isRebuildNeeded(); - -} diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index 58e390f2e445e6f636a6118bdcd1d0826d773145..1f3e580b8fa8c3ae0747a876e61f4448e3749f71 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -39,13 +39,6 @@ class RouteProvider implements RouteProviderInterface, PagedRouteProviderInterfa */ protected $tableName; - /** - * The route builder. - * - * @var \Drupal\Core\Routing\RouteBuilderInterface - */ - protected $routeBuilder; - /** * The state. * @@ -72,8 +65,6 @@ class RouteProvider implements RouteProviderInterface, PagedRouteProviderInterfa * * @param \Drupal\Core\Database\Connection $connection * A database connection object. - * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder - * The route builder. * @param \Drupal\Core\State\StateInterface $state * The state. * @param \Drupal\Core\Path\CurrentPathStack $current_path @@ -81,9 +72,8 @@ class RouteProvider implements RouteProviderInterface, PagedRouteProviderInterfa * @param string $table * The table in the database to use for matching. */ - public function __construct(Connection $connection, RouteBuilderInterface $route_builder, StateInterface $state, CurrentPathStack $current_path, $table = 'router') { + public function __construct(Connection $connection, StateInterface $state, CurrentPathStack $current_path, $table = 'router') { $this->connection = $connection; - $this->routeBuilder = $route_builder; $this->state = $state; $this->tableName = $table; $this->currentPath = $current_path; @@ -117,14 +107,7 @@ public function __construct(Connection $connection, RouteBuilderInterface $route public function getRouteCollectionForRequest(Request $request) { $path = $this->currentPath->getPath($request); - $collection = $this->getRoutesByPath(rtrim($path, '/')); - - // Try rebuilding the router if it is necessary. - if (!$collection->count() && $this->routeBuilder->rebuildIfNeeded()) { - $collection = $this->getRoutesByPath($path); - } - - return $collection; + return $this->getRoutesByPath(rtrim($path, '/')); } /** @@ -170,8 +153,6 @@ public function getRoutesByNames($names) { throw new \InvalidArgumentException('You must specify the route names to load'); } - $this->routeBuilder->rebuildIfNeeded(); - $routes_to_load = array_diff($names, array_keys($this->routes)); if ($routes_to_load) { $result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', array(':names[]' => $routes_to_load)); @@ -257,7 +238,6 @@ public function getCandidateOutlines(array $parts) { */ public function getRoutesByPattern($pattern) { $path = RouteCompiler::getPatternOutline($pattern); - $this->routeBuilder->rebuildIfNeeded(); return $this->getRoutesByPath($path); } diff --git a/core/modules/book/src/Tests/BookUninstallTest.php b/core/modules/book/src/Tests/BookUninstallTest.php index 317a16ae1e36ae811f056df3bc32e1638299b281..dbd4de5186bf8fa42dd57afbca0ccada55b0c9e1 100644 --- a/core/modules/book/src/Tests/BookUninstallTest.php +++ b/core/modules/book/src/Tests/BookUninstallTest.php @@ -30,6 +30,7 @@ class BookUninstallTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router')); $this->installEntitySchema('user'); $this->installEntitySchema('node'); $this->installSchema('book', array('book')); diff --git a/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php b/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php index 83986eb5570a75f014fa5aaad04be5360b9da49b..e21723a257c660700352bf85ba174cde036befa7 100644 --- a/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php +++ b/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php @@ -20,10 +20,11 @@ class BreakpointDiscoveryTest extends KernelTestBase { * * @var array */ - public static $modules = array('breakpoint', 'breakpoint_module_test'); + public static $modules = array('system', 'breakpoint', 'breakpoint_module_test'); protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router')); \Drupal::service('theme_handler')->install(array('breakpoint_theme_test')); } diff --git a/core/modules/ckeditor/src/Tests/CKEditorTest.php b/core/modules/ckeditor/src/Tests/CKEditorTest.php index 25558d38dffa75a2b9160e4ec1a42f65aedd685e..ab303b60d4e69651ef55ae550e3ba4692d82374f 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php @@ -44,6 +44,7 @@ protected function setUp() { // Install the Filter module. $this->installSchema('system', 'url_alias'); + $this->installSchema('system', 'router'); // Create text format, associate CKEditor. $filtered_html_format = entity_create('filter_format', array( diff --git a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php index 3cb8ab0d8f9d6ac9c9ecdccee3e632a3e4b1e706..ddfaf8f2c7cc51ddce675434b0f88c0a7455b1ac 100644 --- a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php @@ -29,6 +29,7 @@ class CommentStringIdEntitiesTest extends KernelTestBase { 'field_ui', 'entity', 'entity_test', + 'system', 'text', ); @@ -36,6 +37,7 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('comment'); $this->installSchema('comment', array('comment_entity_statistics')); + $this->installSchema('system', array('router')); // Create the comment body field storage. $this->installConfig(array('field')); } diff --git a/core/modules/config/src/Tests/ConfigCRUDTest.php b/core/modules/config/src/Tests/ConfigCRUDTest.php index f42d722b9c108fe241ee729684a9d022661f0ea0..c530b962cb2c829e7fa42a3fb0bbfe99736a7c8e 100644 --- a/core/modules/config/src/Tests/ConfigCRUDTest.php +++ b/core/modules/config/src/Tests/ConfigCRUDTest.php @@ -39,6 +39,11 @@ class ConfigCRUDTest extends KernelTestBase { */ public static $modules = array('system'); + protected function setUp() { + parent::setUp(); + $this->installSchema('system', 'router'); + } + /** * Tests CRUD operations. */ diff --git a/core/modules/config/src/Tests/DefaultConfigTest.php b/core/modules/config/src/Tests/DefaultConfigTest.php index 99ff07a6d5159affe012ed8d5ecc4c6e1e50dab6..2d5412c0c98f53143290cd615f77a700faea4269 100644 --- a/core/modules/config/src/Tests/DefaultConfigTest.php +++ b/core/modules/config/src/Tests/DefaultConfigTest.php @@ -45,6 +45,7 @@ class DefaultConfigTest extends KernelTestBase { protected function setUp() { parent::setUp(); + $this->installSchema('system', 'router'); \Drupal::service('theme_handler')->install($this->themes); } diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index fbb3a78a049d46833c8edcc0bfa1fd7ff4919842..2c55fa9a8be83be9546a37830641e9e48dea847b 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -295,7 +295,7 @@ function content_translation_form_language_content_settings_submit(array $form, // Ensure entity and menu router information are correctly rebuilt. \Drupal::entityManager()->clearCachedDefinitions(); - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); // If an entity type is not translatable all its bundles and fields must be // marked as non-translatable. Similarly, if a bundle is made non-translatable diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 8f5e8fd99f38531c6a111abfa1e4b78eb22f04b6..93d73f9d6dc6d003bd26904d74f29590ea2e1f84 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -477,7 +477,7 @@ function content_translation_language_configuration_element_submit(array $form, if (\Drupal::service('content_translation.manager')->isEnabled($context['entity_type'], $context['bundle']) != $enabled) { \Drupal::service('content_translation.manager')->setEnabled($context['entity_type'], $context['bundle'], $enabled); \Drupal::entityManager()->clearCachedDefinitions(); - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } } diff --git a/core/modules/field/src/Tests/FieldAttachOtherTest.php b/core/modules/field/src/Tests/FieldAttachOtherTest.php index f3b0f6794f2b74714c3a0dd6d4613262b0ec34ee..af92af7bc6e9ff9ee8d4520daa6929b54c68be43 100644 --- a/core/modules/field/src/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/src/Tests/FieldAttachOtherTest.php @@ -20,7 +20,6 @@ class FieldAttachOtherTest extends FieldUnitTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->container->get('router.builder')->rebuild(); $this->installEntitySchema('entity_test_rev'); $this->createFieldWithStorage(); diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php index 3e83c4d46034c0bde1f15dfd498d8b553607c78a..d71be2edd18727aafec073e3a3f1c3d55d4c6ec5 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php @@ -29,7 +29,6 @@ protected function setUp() { // Module uninstall requires the router and users_data tables. // @see drupal_flush_all_caches() // @see user_modules_uninstalled() - $this->installSchema('system', array('router')); $this->installSchema('user', array('users_data')); } diff --git a/core/modules/field/src/Tests/FieldUnitTestBase.php b/core/modules/field/src/Tests/FieldUnitTestBase.php index 0b0895fcf7fbd284aad3a01711edfc3189068e71..3c2b53546207999b8d72caaed3fec1279dc332d5 100644 --- a/core/modules/field/src/Tests/FieldUnitTestBase.php +++ b/core/modules/field/src/Tests/FieldUnitTestBase.php @@ -51,6 +51,7 @@ protected function setUp() { $this->installEntitySchema('entity_test'); $this->installEntitySchema('user'); $this->installSchema('system', array('sequences')); + $this->installSchema('system', array('router')); // Set default storage backend and configure the theme system. $this->installConfig(array('field', 'system')); diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 64b62efae87eee3ec2ee854ab0fea5bab622f63f..5c2e22f604d94cd44456b6664bb80eb2e6d36743 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -80,7 +80,7 @@ function field_ui_entity_type_build(array &$entity_types) { function field_ui_entity_bundle_create($entity_type, $bundle) { // When a new bundle is created, the menu needs to be rebuilt to add our // menu item tabs. - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** @@ -89,7 +89,7 @@ function field_ui_entity_bundle_create($entity_type, $bundle) { function field_ui_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) { // When a bundle is renamed, the menu needs to be rebuilt to add our // menu item tabs. - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** @@ -169,28 +169,28 @@ function field_ui_form_node_type_form_submit($form, FormStateInterface $form_sta * Implements hook_entity_view_mode_presave(). */ function field_ui_entity_view_mode_presave(EntityViewModeInterface $view_mode) { - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** * Implements hook_entity_form_mode_presave(). */ function field_ui_entity_form_mode_presave(EntityFormModeInterface $form_mode) { - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** * Implements hook_entity_view_mode_delete(). */ function field_ui_entity_view_mode_delete(EntityViewModeInterface $view_mode) { - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** * Implements hook_entity_form_mode_delete(). */ function field_ui_entity_form_mode_delete(EntityFormModeInterface $form_mode) { - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index ef0f4768cf1c1fca7cc3ad90ed3d27757577f11c..9cedc2d93d98ab6c9603df2d35a049a6d7832349 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -26,6 +26,7 @@ class EntityDisplayTest extends KernelTestBase { protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router')); $this->installEntitySchema('node'); $this->installConfig(array('field')); } diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php index 6ca3df969caf3ad7be42bf926e3ca31067827f2b..5fd8ec0cf14def85d63bde27c4188cad50a87d17 100644 --- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php @@ -80,6 +80,8 @@ public function testFieldUIRoutes() { 'label' => 'Test', 'targetEntityType' => 'user', ))->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); + $edit = array('display_modes_custom[test]' => TRUE); $this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save')); $this->assertLink('Test'); @@ -91,6 +93,8 @@ public function testFieldUIRoutes() { 'label' => 'Test', 'targetEntityType' => 'user', ))->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); + $edit = array('display_modes_custom[test]' => TRUE); $this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save')); $this->assertLink('Test'); diff --git a/core/modules/filter/src/Tests/FilterAPITest.php b/core/modules/filter/src/Tests/FilterAPITest.php index 6ee11e28fa943495bc9673bbce326c7049d2e5c6..3ceb5eb4a7adcd3c15b82c6f6d5adc8ebde36a3f 100644 --- a/core/modules/filter/src/Tests/FilterAPITest.php +++ b/core/modules/filter/src/Tests/FilterAPITest.php @@ -28,6 +28,7 @@ class FilterAPITest extends EntityUnitTestBase { protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router')); $this->installConfig(array('system', 'filter')); } diff --git a/core/modules/link/src/Tests/LinkItemTest.php b/core/modules/link/src/Tests/LinkItemTest.php index 017c83ecb64db99a1d85b41a22ff996a8ec77026..b39d4be09a1856e4236225a562bb32214a301f01 100644 --- a/core/modules/link/src/Tests/LinkItemTest.php +++ b/core/modules/link/src/Tests/LinkItemTest.php @@ -28,7 +28,6 @@ class LinkItemTest extends FieldUnitTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', ['router']); // Create a link field for validation. entity_create('field_storage_config', array( diff --git a/core/modules/menu_ui/menu_ui.install b/core/modules/menu_ui/menu_ui.install index c2aadce1b1483b64c8ced637fcb7890c03ea16e6..a75a02ca6daab5794e059885c0da0582a7279f4b 100644 --- a/core/modules/menu_ui/menu_ui.install +++ b/core/modules/menu_ui/menu_ui.install @@ -21,5 +21,5 @@ function menu_ui_install() { * Implements hook_uninstall(). */ function menu_ui_uninstall() { - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 611ae17d4dd70c970eb73c07e037f43d94352e6b..f181df188eae08319b4086a2ef937181cf191aa5 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -880,7 +880,7 @@ function node_form_system_themes_admin_form_submit($form, FormStateInterface $fo \Drupal::configFactory()->getEditable('node.settings') ->set('use_admin_theme', $form_state->getValue('use_admin_theme')) ->save(); - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** diff --git a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php index 97fe51f7252d1178da2a23729b13404e04554694..f6902e3964cc10dd983331556329bbfd55023124 100644 --- a/core/modules/node/src/Tests/Config/NodeImportCreateTest.php +++ b/core/modules/node/src/Tests/Config/NodeImportCreateTest.php @@ -30,6 +30,7 @@ class NodeImportCreateTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router')); $this->installEntitySchema('user'); // Set default storage backend. diff --git a/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php b/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php index bdfa24c9c91bd4e8704df40d7012c29a610d72ec..6e606f54a7d37b686e0d4923a5f052cb3b939203 100644 --- a/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php +++ b/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php @@ -32,6 +32,7 @@ class NodeBodyFieldStorageTest extends KernelTestBase { protected function setUp() { parent::setUp(); $this->installSchema('system', 'sequences'); + $this->installSchema('system', array('router')); // Necessary for module uninstall. $this->installSchema('user', 'users_data'); $this->installEntitySchema('user'); diff --git a/core/modules/node/src/Tests/Views/NodeLanguageTest.php b/core/modules/node/src/Tests/Views/NodeLanguageTest.php index d2101abaa0535bf08326b72bb278031df59d1395..64e4d4da688cf6f5e76ca1f65ff4f864cd114b15 100644 --- a/core/modules/node/src/Tests/Views/NodeLanguageTest.php +++ b/core/modules/node/src/Tests/Views/NodeLanguageTest.php @@ -90,6 +90,7 @@ protected function setUp() { } $node->save(); } + $this->container->get('router.builder')->rebuild(); $user = $this->drupalCreateUser(array('access content overview', 'access content')); $this->drupalLogin($user); diff --git a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php index a254a0a2e10601d97285bf25f4b2d4e2b96acac0..fcfe4f8acd2e6b40710f8ebe7fd66243ee6b9b03 100644 --- a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php +++ b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php @@ -55,7 +55,6 @@ abstract class OptionsFieldUnitTestBase extends FieldUnitTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); $this->container->get('router.builder')->rebuild(); $this->fieldStorageDefinition = array( diff --git a/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php b/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php index adddda12dea683c732f293a403f50819f4fb2bfd..61613269ed22688a4263c34256471ee3afe25774 100644 --- a/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php +++ b/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php @@ -63,7 +63,6 @@ abstract class FieldRdfaTestBase extends FieldUnitTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('router')); \Drupal::service('router.builder')->rebuild(); } diff --git a/core/modules/search/src/Entity/SearchPage.php b/core/modules/search/src/Entity/SearchPage.php index d8cfc41eb73365c7ed784fd57f93959d75d4d738..0f583c750db84c65a152cf2a8825ec8416232ea5 100644 --- a/core/modules/search/src/Entity/SearchPage.php +++ b/core/modules/search/src/Entity/SearchPage.php @@ -184,7 +184,7 @@ public function postCreate(EntityStorageInterface $storage) { */ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); - $this->routeBuilderIndicator()->setRebuildNeeded(); + $this->routeBuilder()->setRebuildNeeded(); } /** @@ -216,11 +216,11 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) /** * Wraps the route builder. * - * @return \Drupal\Core\Routing\RouteBuilderIndicatorInterface + * @return \Drupal\Core\Routing\RouteBuilderInterface * An object for state storage. */ - protected function routeBuilderIndicator() { - return \Drupal::service('router.builder_indicator'); + protected function routeBuilder() { + return \Drupal::service('router.builder'); } /** diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index 218d0b989aa8f0efda3aeaada55c0732acaa3e02..8d2382e6d781caaf0b1e4c9ea85224fa66b52d7d 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -21,7 +21,7 @@ class KernelTestBaseTest extends KernelTestBase { * * @var array */ - public static $modules = array('entity_test'); + public static $modules = array('entity_test', 'system'); /** * {@inheritdoc} @@ -44,6 +44,7 @@ function simpletest_test_stub_settings_function() {} $original_container = $this->originalContainer; parent::setUp(); + $this->installSchema('system', array('router')); $this->assertNotIdentical(\Drupal::getContainer(), $original_container, 'KernelTestBase test creates a new container.'); } @@ -51,7 +52,7 @@ function simpletest_test_stub_settings_function() {} * Tests expected behavior of setUp(). */ function testSetUp() { - $modules = array('entity_test'); + $modules = array('entity_test', 'system'); $table = 'entity_test'; // Verify that specified $modules have been loaded. diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index dd096caa516668df36f9f901b73b494721139d66..5ebaca65fb49938de896dafebbb9287732109375 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -722,7 +722,7 @@ function hook_entity_bundle_info_alter(&$bundles) { function hook_entity_bundle_create($entity_type_id, $bundle) { // When a new bundle is created, the menu needs to be rebuilt to add the // Field UI menu item tabs. - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } /** diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php index f1d1b9e00f24b01fc44bec503d1b6126547a00ef..dd5f74984bfb3e6c576bbe372391d1d837b7daa4 100644 --- a/core/modules/system/src/Controller/ThemeController.php +++ b/core/modules/system/src/Controller/ThemeController.php @@ -11,7 +11,7 @@ use Drupal\Core\Config\PreExistingConfigException; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ThemeHandlerInterface; -use Drupal\Core\Routing\RouteBuilderIndicatorInterface; +use Drupal\Core\Routing\RouteBuilderInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -31,24 +31,24 @@ class ThemeController extends ControllerBase { /** * The route builder service. * - * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface + * @var \Drupal\Core\Routing\RouteBuilderInterface */ - protected $routeBuilderIndicator; + protected $routeBuilder; /** * Constructs a new ThemeController. * * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler. - * @param \Drupal\Core\Routing\RouteBuilderIndicatorInterface $route_builder_indicator + * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder * The route builder. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ - public function __construct(ThemeHandlerInterface $theme_handler, RouteBuilderIndicatorInterface $route_builder_indicator, ConfigFactoryInterface $config_factory) { + public function __construct(ThemeHandlerInterface $theme_handler, RouteBuilderInterface $route_builder, ConfigFactoryInterface $config_factory) { $this->themeHandler = $theme_handler; - $this->routeBuilderIndicator = $route_builder_indicator; $this->configFactory = $config_factory; + $this->routeBuilder = $route_builder; } /** @@ -57,7 +57,7 @@ public function __construct(ThemeHandlerInterface $theme_handler, RouteBuilderIn public static function create(ContainerInterface $container) { return new static( $container->get('theme_handler'), - $container->get('router.builder_indicator'), + $container->get('router.builder'), $container->get('config.factory') ); } @@ -179,7 +179,7 @@ public function setDefaultTheme(Request $request) { // Set the default theme. $config->set('default', $theme)->save(); - $this->routeBuilderIndicator->setRebuildNeeded(); + $this->routeBuilder->setRebuildNeeded(); // The status message depends on whether an admin theme is currently in // use: a value of 0 means the admin theme is set to be the default diff --git a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php index 60b7281961a9197abf45abe7b263056d3dbc1c87..164b1e91ab7e56a266abd914dfd68231ceb3a67d 100644 --- a/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php +++ b/core/modules/system/src/Tests/Condition/CurrentThemeConditionTest.php @@ -22,6 +22,14 @@ class CurrentThemeConditionTest extends KernelTestBase { */ public static $modules = array('system', 'theme_test'); + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->installSchema('system', array('router')); + } + /** * Tests the current theme condition. */ diff --git a/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php b/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php index f427ade3443be0d484aced81b4114ba0769d49f7..ea467471437bf84ae4174cdeaae24fc32acf658c 100644 --- a/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php +++ b/core/modules/system/src/Tests/Field/FieldModuleUninstallValidatorTest.php @@ -31,6 +31,7 @@ class FieldModuleUninstallValidatorTest extends EntityUnitTestBase { */ protected function setUp() { parent::setUp(); + $this->installSchema('system', 'router'); $this->installSchema('user', 'users_data'); $this->entityDefinitionUpdateManager = $this->container->get('entity.definition_update_manager'); diff --git a/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php b/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php index 2a34c20d0537ae7e653d70d5c96652319bb12cc5..b831830bf37c67f1d59706f4ee647deb1bdc5e17 100644 --- a/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php +++ b/core/modules/system/src/Tests/Module/ModuleImplementsAlterTest.php @@ -16,6 +16,16 @@ */ class ModuleImplementsAlterTest extends KernelTestBase { + public static $modules = array('system'); + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->installSchema('system', array('router')); + } + /** * Tests hook_module_implements_alter() adding an implementation. * diff --git a/core/modules/system/src/Tests/Routing/RouteProviderTest.php b/core/modules/system/src/Tests/Routing/RouteProviderTest.php index f8e4c5a5dcbb1a587a1f75f3ad67a35ec88888b2..c9af8868eb302f71f003e69b114921e011c7d504 100644 --- a/core/modules/system/src/Tests/Routing/RouteProviderTest.php +++ b/core/modules/system/src/Tests/Routing/RouteProviderTest.php @@ -21,7 +21,6 @@ use Drupal\Core\Database\Database; use Drupal\Core\Routing\MatcherDumper; use Drupal\Tests\Core\Routing\RoutingFixtures; -use Drupal\Tests\Core\Routing\NullRouteBuilder; /** * Confirm that the default route provider is working correctly. @@ -37,13 +36,6 @@ class RouteProviderTest extends KernelTestBase { */ protected $fixtures; - /** - * A null route builder to enable testing of the route provider. - * - * @var \Drupal\Core\Routing\RouteBuilderInterface - */ - protected $routeBuilder; - /** * The state. * @@ -61,7 +53,6 @@ class RouteProviderTest extends KernelTestBase { protected function setUp() { parent::setUp(); $this->fixtures = new RoutingFixtures(); - $this->routeBuilder = new NullRouteBuilder(); $this->state = new State(new KeyValueMemoryFactory()); $this->currentPath = new CurrentPathStack(new RequestStack()); } @@ -78,7 +69,7 @@ protected function tearDown() { public function testCandidateOutlines() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $parts = array('node', '5', 'edit'); @@ -101,7 +92,7 @@ public function testCandidateOutlines() { */ function testExactPathMatch() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -125,7 +116,7 @@ function testExactPathMatch() { */ function testOutlinePathMatch() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -154,7 +145,7 @@ function testOutlinePathMatch() { */ function testOutlinePathMatchTrailingSlash() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -183,7 +174,7 @@ function testOutlinePathMatchTrailingSlash() { */ function testOutlinePathMatchDefaults() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -221,7 +212,7 @@ function testOutlinePathMatchDefaults() { */ function testOutlinePathMatchDefaultsCollision() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -260,7 +251,7 @@ function testOutlinePathMatchDefaultsCollision() { */ function testOutlinePathMatchDefaultsCollision2() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -299,7 +290,7 @@ function testOutlinePathMatchDefaultsCollision2() { */ public function testOutlinePathMatchZero() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -334,7 +325,7 @@ public function testOutlinePathMatchZero() { */ function testOutlinePathNoMatch() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -359,7 +350,7 @@ function testOutlinePathNoMatch() { */ function testCurrentPath() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -384,7 +375,7 @@ function testCurrentPath() { */ public function testRouteByName() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); @@ -419,7 +410,7 @@ public function testRouteByName() { */ public function testGetRoutesByPatternWithLongPatterns() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); // This pattern has only 3 parts, so we will get candidates, but no routes, @@ -477,7 +468,7 @@ public function testGetRoutesByPatternWithLongPatterns() { */ public function testGetRoutesPaged() { $connection = Database::getConnection(); - $provider = new RouteProvider($connection, $this->routeBuilder, $this->state, $this->currentPath, 'test_routes'); + $provider = new RouteProvider($connection, $this->state, $this->currentPath, 'test_routes'); $this->fixtures->createTables($connection); $dumper = new MatcherDumper($connection, $this->state, 'test_routes'); diff --git a/core/modules/system/src/Tests/System/InfoAlterTest.php b/core/modules/system/src/Tests/System/InfoAlterTest.php index 02cdd1771e684d72fe80c5ceee2a08f1216aa6fa..42f5041363d5c7b034651986af0f19d3864ced39 100644 --- a/core/modules/system/src/Tests/System/InfoAlterTest.php +++ b/core/modules/system/src/Tests/System/InfoAlterTest.php @@ -18,6 +18,14 @@ class InfoAlterTest extends KernelTestBase { public static $modules = array('system'); + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->installSchema('system', array('router')); + } + /** * Tests that theme .info.yml data is rebuild after enabling a module. * diff --git a/core/modules/system/src/Tests/Theme/RegistryTest.php b/core/modules/system/src/Tests/Theme/RegistryTest.php index 22f0cde15ba24304cad9434618cf40ac420f4b52..763372e5ada10e92318cbc9a8556f59736bfeb2e 100644 --- a/core/modules/system/src/Tests/Theme/RegistryTest.php +++ b/core/modules/system/src/Tests/Theme/RegistryTest.php @@ -26,6 +26,16 @@ class RegistryTest extends KernelTestBase { public static $modules = array('theme_test', 'system'); protected $profile = 'testing'; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->installSchema('system', ['router']); + } + /** * Tests the behavior of the theme registry class. */ diff --git a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php index 3ef48d088d0c612cb0afc467752630898624ce6f..09d73e7acf684fac1fb8a18478a41d6cba6bef97 100644 --- a/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeSettingsTest.php @@ -34,6 +34,7 @@ class ThemeSettingsTest extends KernelTestBase { protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router')); // Theme settings rely on System module's system.theme.global configuration. $this->installConfig(array('system')); diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php index cfc76bdff12f61edc486860ee23837e1bb068c7f..d58b2d5a76031ad0324712f6d070a2c4bf4cc27d 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php @@ -93,7 +93,7 @@ function setUp() { Views::viewsData()->clear(); ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views')); - + $this->container->get('router.builder')->rebuild(); } /** diff --git a/core/modules/user/src/Tests/Views/AccessRoleTest.php b/core/modules/user/src/Tests/Views/AccessRoleTest.php index bd550223e25cedcd22d5aa6e64542d7b9453600b..f79e86effa394f7c38629a70969f5e9dcace162c 100644 --- a/core/modules/user/src/Tests/Views/AccessRoleTest.php +++ b/core/modules/user/src/Tests/Views/AccessRoleTest.php @@ -30,13 +30,14 @@ class AccessRoleTest extends AccessTestBase { * Tests role access plugin. */ function testAccessRole() { - /** @var \Drupal\views\ViewentityInterface $view */ + /** @var \Drupal\views\ViewEntityInterface $view */ $view = \Drupal::entityManager()->getStorage('view')->load('test_access_role'); $display = &$view->getDisplay('default'); $display['display_options']['access']['options']['role'] = array( $this->normalRole => $this->normalRole, ); $view->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); $expected = [ 'config' => ['user.role.' . $this->normalRole], 'module' => ['user'], @@ -69,6 +70,7 @@ function testAccessRole() { 'anonymous' => 'anonymous', ); $view->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); // Ensure that the list of roles is sorted correctly, if the generated role // ID comes before 'anonymous', see https://www.drupal.org/node/2398259. diff --git a/core/modules/user/src/Tests/Views/UserUnitTestBase.php b/core/modules/user/src/Tests/Views/UserUnitTestBase.php index 672bae7b0b4bb40f0f26affdafa43564f6d5d5b8..433719f21b707768d1f175bb11726a024c8dcac4 100644 --- a/core/modules/user/src/Tests/Views/UserUnitTestBase.php +++ b/core/modules/user/src/Tests/Views/UserUnitTestBase.php @@ -49,7 +49,6 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('user_test_views')); $this->installEntitySchema('user'); - $this->installSchema('system', 'sequences'); $entity_manager = $this->container->get('entity.manager'); $this->roleStorage = $entity_manager->getStorage('user_role'); diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index daca68fe8123377b61d31885a6ef8bc7911c5230..51ad1a662b5f5f8dca55e077b45447acd62301ef 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -333,9 +333,9 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { // @todo Remove if views implements a view_builder controller. views_invalidate_cache(); - // Rebuild the router case the view got enabled. + // Rebuild the router if this is a new view, or it's status changed. if (!isset($this->original) || ($this->status() != $this->original->status())) { - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); } } diff --git a/core/modules/views/src/Tests/GlossaryTest.php b/core/modules/views/src/Tests/GlossaryTest.php index 2b0534a7ed4dd4a2befb5d43c7c8e8886560aca0..fd979780957bcf283c45b642a6662bbd28dbfb3b 100644 --- a/core/modules/views/src/Tests/GlossaryTest.php +++ b/core/modules/views/src/Tests/GlossaryTest.php @@ -68,6 +68,7 @@ public function testGlossaryView() { // Enable the glossary to be displayed. $view->storage->enable()->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); // Check the actual page response. $this->drupalGet('glossary'); $this->assertResponse(200); diff --git a/core/modules/views/src/Tests/Plugin/CacheTest.php b/core/modules/views/src/Tests/Plugin/CacheTest.php index d730abf89e5979fa8105513f1a69347439dc2508..9e2c6c4efe6e4271b794fc8fa725db79cc90f221 100644 --- a/core/modules/views/src/Tests/Plugin/CacheTest.php +++ b/core/modules/views/src/Tests/Plugin/CacheTest.php @@ -253,6 +253,8 @@ public function testCacheOutputOnPage() { ) )); $view->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); + $output_key = $view->getDisplay()->getPlugin('cache')->generateOutputKey(); $this->assertFalse(\Drupal::cache('render')->get($output_key)); diff --git a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php index 4cfce8c0a03c354bf9c1d7820be36604a7b5c44c..e9052b4bf1889fa1ac4f72257afb38866880bd16 100644 --- a/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php +++ b/core/modules/views/src/Tests/Plugin/DisabledDisplayTest.php @@ -73,6 +73,8 @@ public function testDisabledDisplays() { $this->assertTrue($enabled, 'Display ' . $display_id . ' is now enabled'); } + \Drupal::service('router.builder')->rebuildIfNeeded(); + // Check that the originally disabled page_2 display is now enabled. $this->drupalGet('test-disabled-display-2'); $result = $this->xpath('//h1'); @@ -86,6 +88,8 @@ public function testDisabledDisplays() { $this->assertFalse($enabled, 'Display ' . $display_id . ' is now disabled'); } + \Drupal::service('router.builder')->rebuild(); + // Check that the page_1 display still works. $this->drupalGet('test-disabled-display'); $this->assertResponse(200); diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php index 4222f178c35bff511163448386e61e205417ffda..373fe5afb87a571441e56ba95ae9e0c549fe58ad 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php @@ -80,7 +80,7 @@ public function testPageResponses() { $view->storage->disable()->save(); // Router rebuild would occur in a kernel terminate event so we need to // simulate that here. - \Drupal::service('router.builder')->rebuildIfNeeded(); + \Drupal::service('router.builder')->rebuild(); $response = $this->container->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST); $this->assertEqual($response->getStatusCode(), 404); diff --git a/core/modules/views/src/Tests/Plugin/RelationshipJoinTestBase.php b/core/modules/views/src/Tests/Plugin/RelationshipJoinTestBase.php index b85c2351e59c59dac63429c4401c9a49f9c637fa..5620c0aa1557acdf1b64099e8acac8c71abfdcc4 100644 --- a/core/modules/views/src/Tests/Plugin/RelationshipJoinTestBase.php +++ b/core/modules/views/src/Tests/Plugin/RelationshipJoinTestBase.php @@ -24,6 +24,11 @@ abstract class RelationshipJoinTestBase extends PluginUnitTestBase { */ public static $modules = array('system', 'user', 'field'); + /** + * @var \Drupal\user\Entity\User + */ + protected $rootUser; + /** * Overrides \Drupal\views\Tests\ViewUnitTestBase::setUpFixtures(). */ @@ -33,9 +38,8 @@ protected function setUpFixtures() { parent::setUpFixtures(); // Create a record for uid 1. - $this->installSchema('system', 'sequences'); - $root_user = entity_create('user', array('name' => $this->randomMachineName())); - $root_user->save(); + $this->rootUser = entity_create('user', array('name' => $this->randomMachineName())); + $this->rootUser->save(); Views::viewsData()->clear(); } diff --git a/core/modules/views/src/Tests/ViewTestData.php b/core/modules/views/src/Tests/ViewTestData.php index 03c4baef6ebd9cb4071120dc83c198f71100b8ea..4b5340ea960324424b495b5adf75767f296efed7 100644 --- a/core/modules/views/src/Tests/ViewTestData.php +++ b/core/modules/views/src/Tests/ViewTestData.php @@ -56,6 +56,9 @@ public static function createTestViews($class, array $modules) { } } } + + // Rebuild the router once. + \Drupal::service('router.builder')->rebuild(); } /** diff --git a/core/modules/views/src/Tests/ViewUnitTestBase.php b/core/modules/views/src/Tests/ViewUnitTestBase.php index 16b1e38ee147ee72a4515c44a3bcc2157cbb36c1..2de7f2bb2999c3094c1fe71e32f02b974565b8fd 100644 --- a/core/modules/views/src/Tests/ViewUnitTestBase.php +++ b/core/modules/views/src/Tests/ViewUnitTestBase.php @@ -36,6 +36,7 @@ abstract class ViewUnitTestBase extends KernelTestBase { protected function setUp() { parent::setUp(); + $this->installSchema('system', array('router', 'sequences')); $this->setUpFixtures(); } @@ -59,8 +60,6 @@ protected function setUpFixtures() { $this->installSchema('views_test_data', $table); } - // The router table is required for router rebuilds. - $this->installSchema('system', array('router')); \Drupal::service('router.builder')->rebuild(); // Load the test dataset. diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 03c27d606d585313b4094485c057a3b030222c5e..23fd877a2d5bce7ad4881bf89248f813a7c127bd 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -484,7 +484,7 @@ function views_field_config_delete(FieldConfigInterface $field) { */ function views_invalidate_cache() { // Set the menu as needed to be rebuilt. - \Drupal::service('router.builder_indicator')->setRebuildNeeded(); + \Drupal::service('router.builder')->setRebuildNeeded(); $module_handler = \Drupal::moduleHandler(); diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php index eca12a4087596fdf03daa85e82cba921da7f5db9..1b4d04c2b9e26bb8b4136249766c8b07fa4798b0 100644 --- a/core/modules/views_ui/src/Tests/DisplayTest.php +++ b/core/modules/views_ui/src/Tests/DisplayTest.php @@ -178,6 +178,7 @@ public function testPageContextualLinks() { $this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links'))); $view = entity_load('view', 'test_display'); $view->enable()->save(); + $this->container->get('router.builder')->rebuildIfNeeded(); $this->drupalGet('test-display'); $id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1'; diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index 2c9a01562ead146dc8acc7927463ffd1e6b53d0f..84d426615307444cdd30d1d1b465b82d515da077 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -22,11 +22,11 @@ class ThemeHandlerTest extends UnitTestCase { /** - * The mocked route builder indicator. + * The mocked route builder. * - * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Routing\RouteBuilderInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $routeBuilderIndicator; + protected $routeBuilder; /** * The mocked info parser. @@ -111,7 +111,7 @@ protected function setUp() { $this->infoParser = $this->getMock('Drupal\Core\Extension\InfoParserInterface'); $this->configInstaller = $this->getMock('Drupal\Core\Config\ConfigInstallerInterface'); $this->configManager = $this->getMock('Drupal\Core\Config\ConfigManagerInterface'); - $this->routeBuilderIndicator = $this->getMock('Drupal\Core\Routing\RouteBuilderIndicatorInterface'); + $this->routeBuilder = $this->getMock('Drupal\Core\Routing\RouteBuilderInterface'); $this->extensionDiscovery = $this->getMockBuilder('Drupal\Core\Extension\ExtensionDiscovery') ->disableOriginalConstructor() ->getMock(); @@ -119,7 +119,7 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); $logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->themeHandler = new TestThemeHandler($this->root, $this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilderIndicator, $this->extensionDiscovery); + $this->themeHandler = new TestThemeHandler($this->root, $this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilder, $this->extensionDiscovery); $cache_tags_invalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface'); $this->getContainerWithCacheTagsInvalidator($cache_tags_invalidator); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php index 8502d7e4f459f1a1b6a5576c71bf1e187eb5a82f..937be5ab43286f033120a0975db9b9b31aad1097 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -187,9 +187,6 @@ public function testGetLocalTaskForRouteWithEmptyCache() { ->method('set') ->with('local_task_plugins:en', $definitions, Cache::PERMANENT); - $this->routeBuilder->expects($this->once()) - ->method('rebuildIfNeeded'); - $expected_set = $this->getLocalTasksCache(); $this->cacheBackend->expects($this->at(3)) @@ -223,7 +220,7 @@ public function testGetLocalTaskForRouteWithFilledCache() { ->method('set'); $this->routeBuilder->expects($this->never()) - ->method('rebuildIfNeeded'); + ->method('rebuild'); $result = $this->getLocalTasksForRouteResult($mock_plugin); $local_tasks = $this->manager->getLocalTasksForRoute('menu_local_task_test_tasks_view'); diff --git a/core/tests/Drupal/Tests/Core/Routing/NullRouteBuilder.php b/core/tests/Drupal/Tests/Core/Routing/NullRouteBuilder.php deleted file mode 100644 index 55c00c848adab1f504f0732ed6535a29807b4d83..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Tests/Core/Routing/NullRouteBuilder.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -namespace Drupal\Tests\Core\Routing; - -use Drupal\Core\Routing\RouteBuilderInterface; - -class NullRouteBuilder implements RouteBuilderInterface { - - public function rebuild() { - } - - public function rebuildIfNeeded() { - } - - public function setRebuildNeeded() { - } - - public function getCollectionDuringRebuild() { - return FALSE; - } - -} diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php index b0efe77c3e10265e1a1ac1ad466da3c4c36076b4..b8f212fd2c8d50af653f2d83425467813858ec12 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php @@ -71,13 +71,6 @@ class RouteBuilderTest extends UnitTestCase { */ protected $controllerResolver; - /** - * The key value store. - * - * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $routeBuilderIndicator; - /** * @var \Drupal\Core\Access\CheckProviderInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -92,10 +85,9 @@ protected function setUp() { $this->yamlDiscovery = $this->getMockBuilder('\Drupal\Component\Discovery\YamlDiscovery') ->disableOriginalConstructor() ->getMock(); - $this->routeBuilderIndicator = $this->getMock('\Drupal\Core\Routing\RouteBuilderIndicatorInterface'); $this->checkProvider = $this->getMock('\Drupal\Core\Access\CheckProviderInterface'); - $this->routeBuilder = new TestRouteBuilder($this->dumper, $this->lock, $this->dispatcher, $this->moduleHandler, $this->controllerResolver, $this->checkProvider, $this->routeBuilderIndicator); + $this->routeBuilder = new TestRouteBuilder($this->dumper, $this->lock, $this->dispatcher, $this->moduleHandler, $this->controllerResolver, $this->checkProvider); $this->routeBuilder->setYamlDiscovery($this->yamlDiscovery); } @@ -112,9 +104,6 @@ public function testRebuildLockingUnlocking() { ->method('release') ->with('router_rebuild'); - $this->routeBuilderIndicator->expects($this->once()) - ->method('setRebuildDone'); - $this->yamlDiscovery->expects($this->any()) ->method('findAll') ->will($this->returnValue(array())); @@ -262,25 +251,15 @@ public function testRebuildWithProviderBasedRoutes() { /** * Tests \Drupal\Core\Routing\RouteBuilder::rebuildIfNeeded() method. */ - public function testRebuildIfNecessary() { + public function testRebuildIfNeeded() { $this->lock->expects($this->once()) - ->method('acquire') - ->with('router_rebuild') - ->will($this->returnValue(TRUE)); + ->method('acquire') + ->with('router_rebuild') + ->will($this->returnValue(TRUE)); $this->lock->expects($this->once()) - ->method('release') - ->with('router_rebuild'); - - $this->routeBuilderIndicator->expects($this->once()) - ->method('setRebuildNeeded'); - - $this->routeBuilderIndicator->expects($this->once()) - ->method('setRebuildDone'); - - $this->routeBuilderIndicator->expects($this->exactly(2)) - ->method('isRebuildNeeded') - ->will($this->onConsecutiveCalls(TRUE, FALSE)); + ->method('release') + ->with('router_rebuild'); $this->yamlDiscovery->expects($this->any()) ->method('findAll')