diff --git a/core/core.services.yml b/core/core.services.yml index 4c81a7a..c292812 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -290,7 +290,7 @@ services: arguments: ['%container.modules%', '@cache.bootstrap'] theme_handler: class: Drupal\Core\Extension\ThemeHandler - arguments: ['@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder'] + arguments: ['@config.factory', '@module_handler', '@state', '@info_parser', '@logger.channel.default', '@asset.css.collection_optimizer', '@config.installer', '@config.manager', '@router.builder_indicator'] 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'] @@ -529,14 +529,12 @@ services: arguments: ['@database', '@state'] tags: - { name: backend_overridable } - router.builder: - class: Drupal\Core\Routing\RouteBuilderProxy + router.builder_indicator: + class: Drupal\Core\Routing\RouteBuilderIndicator arguments: ['@state'] - calls: - - [setContainer, ['@service_container']] - router.builder.real: + router.builder: class: Drupal\Core\Routing\RouteBuilder - arguments: ['@router.dumper', '@lock', '@event_dispatcher', '@module_handler', '@controller_resolver', '@state'] + arguments: ['@router.dumper', '@lock', '@event_dispatcher', '@module_handler', '@controller_resolver', '@router.builder_indicator'] router.rebuild_subscriber: class: Drupal\Core\EventSubscriber\RouterRebuildSubscriber arguments: ['@router.builder'] diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 727ab68..fe6c080 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -812,7 +812,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // Clear plugin manager caches and flag router to rebuild if requested. \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); - \Drupal::service('router.builder')->setRebuildNeeded(); + \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. @@ -1002,7 +1002,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Clear plugin manager caches and flag router to rebuild if requested. \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions(); - \Drupal::service('router.builder')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); // Update the kernel to exclude the uninstalled modules. \Drupal::service('kernel')->updateModules($module_filenames, $module_filenames); diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 271d6c8..a316f36 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -13,7 +13,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigInstallerInterface; use Drupal\Core\Config\ConfigManagerInterface; -use Drupal\Core\Routing\RouteBuilderInterface; +use Drupal\Core\Routing\RouteBuilderIndicatorInterface; use Drupal\Core\State\StateInterface; use Psr\Log\LoggerInterface; @@ -87,11 +87,11 @@ class ThemeHandler implements ThemeHandlerInterface { protected $logger; /** - * The route builder to rebuild the routes if a theme is installed. + * The route builder indicator to rebuild the routes if a theme is installed. * - * @var \Drupal\Core\Routing\RouteBuilderInterface + * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface */ - protected $routeBuilder; + protected $routeBuilderIndicator; /** * An extension discovery instance. @@ -135,13 +135,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\RouteBuilderInterface $route_builder - * (optional) The route builder to rebuild the routes if a theme is - * installed. + * @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\Extension\ExtensionDiscovery $extension_discovery * (optional) A extension discovery instance (for unit tests). */ - public function __construct(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) { + public function __construct(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) { $this->configFactory = $config_factory; $this->moduleHandler = $module_handler; $this->state = $state; @@ -150,7 +150,7 @@ public function __construct(ConfigFactoryInterface $config_factory, ModuleHandle $this->cssCollectionOptimizer = $css_collection_optimizer; $this->configInstaller = $config_installer; $this->configManager = $config_manager; - $this->routeBuilder = $route_builder; + $this->routeBuilderIndicator = $route_builder_indicator; $this->extensionDiscovery = $extension_discovery; } @@ -648,8 +648,8 @@ protected function getExtensionDiscovery() { * Resets some other systems like rebuilding the route information or caches. */ protected function resetSystem() { - if ($this->routeBuilder) { - $this->routeBuilder->setRebuildNeeded(); + if ($this->routeBuilderIndicator) { + $this->routeBuilderIndicator->setRebuildNeeded(); } $this->systemListReset(); diff --git a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php index f2ca2fc..6e93561 100644 --- a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php +++ b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php @@ -51,7 +51,7 @@ public function register(ContainerBuilder $container) { // Replace the route builder with an empty implementation. // @todo Convert installer steps into routes; add an installer.routing.yml. - $definition = $container->getDefinition('router.builder.real'); + $definition = $container->getDefinition('router.builder'); $definition->setClass('Drupal\Core\Installer\InstallerRouteBuilder'); // Remove dependencies on Drupal's default session handling. diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index 5bea0a5..e201b42 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -59,6 +59,13 @@ class RouteBuilder implements RouteBuilderInterface { protected $moduleHandler; /** + * The route builder indicator. + * + * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface + */ + protected $routeBuilderIndicator; + + /** * The controller resolver. * * @var \Drupal\Core\Controller\ControllerResolverInterface @@ -92,16 +99,16 @@ class RouteBuilder implements RouteBuilderInterface { * The module handler. * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver * The controller resolver. - * @param \Drupal\Core\KeyValueStore\StateInterface $state - * The state. + * @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, StateInterface $state = NULL) { + public function __construct(MatcherDumperInterface $dumper, LockBackendInterface $lock, EventDispatcherInterface $dispatcher, ModuleHandlerInterface $module_handler, ControllerResolverInterface $controller_resolver, RouteBuilderIndicatorInterface $route_build_indicator = NULL) { $this->dumper = $dumper; $this->lock = $lock; $this->dispatcher = $dispatcher; $this->moduleHandler = $module_handler; $this->controllerResolver = $controller_resolver; - $this->state = $state; + $this->routeBuilderIndicator = $route_build_indicator; } /** @@ -175,7 +182,7 @@ public function rebuild() { $this->dumper->addRoutes($collection); $this->dumper->dump(); - $this->state->delete(static::REBUILD_NEEDED); + $this->routeBuilderIndicator->setRebuildDone(); $this->lock->release('router_rebuild'); $this->dispatcher->dispatch(RoutingEvents::FINISHED, new Event()); $this->building = FALSE; @@ -196,7 +203,7 @@ public function getCollectionDuringRebuild() { * {@inheritdoc} */ public function rebuildIfNeeded() { - if ($this->state->get(static::REBUILD_NEEDED, FALSE)) { + if ($this->routeBuilderIndicator->isRebuildNeeded()) { return $this->rebuild(); } return FALSE; @@ -206,7 +213,7 @@ public function rebuildIfNeeded() { * {@inheritdoc} */ public function setRebuildNeeded() { - $this->state->set(static::REBUILD_NEEDED, TRUE); + $this->routeBuilderIndicator->setRebuildNeeded(); } /** diff --git a/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php b/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php new file mode 100644 index 0000000..5f06120 --- /dev/null +++ b/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php @@ -0,0 +1,55 @@ +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 new file mode 100644 index 0000000..68ce5b8 --- /dev/null +++ b/core/lib/Drupal/Core/Routing/RouteBuilderIndicatorInterface.php @@ -0,0 +1,39 @@ +state = $state; - } - - /** - * {@inheritdoc} - */ - public function rebuild() { - return $this->routeBuilder()->rebuild(); - } - - /** - * {@inheritdoc} - */ - public function getCollectionDuringRebuild() { - return $this->routeBuilder()->getCollectionDuringRebuild(); - } - - /** - * {@inheritdoc} - */ - public function rebuildIfNeeded() { - if ($this->state->get(static::REBUILD_NEEDED, FALSE)) { - return $this->rebuild(); - } - return FALSE; - } - - /** - * {@inheritdoc} - */ - public function setRebuildNeeded() { - $this->state->set(static::REBUILD_NEEDED, TRUE); - } - - /** - * @return \Drupal\Core\Routing\RouteBuilderInterface - */ - protected function routeBuilder() { - return $this->container->get('router.builder.real'); - } - -} diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 81473bf..7636150 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -337,5 +337,5 @@ 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')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 3f6d9da..f4e61a8 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -701,7 +701,7 @@ function content_translation_language_configuration_element_submit(array $form, if (content_translation_enabled($context['entity_type'], $context['bundle']) != $enabled) { content_translation_set_config($context['entity_type'], $context['bundle'], 'enabled', $enabled); \Drupal::entityManager()->clearCachedDefinitions(); - \Drupal::service('router.builder')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 246cf3b..c11a6de 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -98,7 +98,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')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** @@ -107,7 +107,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')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** @@ -182,14 +182,14 @@ function field_ui_form_node_type_form_submit($form, FormStateInterface $form_sta * Implements hook_view_mode_presave(). */ function field_ui_view_mode_presave(EntityViewModeInterface $view_mode) { - \Drupal::service('router.builder')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** * Implements hook_view_mode_delete(). */ function field_ui_view_mode_delete(EntityViewModeInterface $view_mode) { - \Drupal::service('router.builder')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** diff --git a/core/modules/menu_ui/menu_ui.install b/core/modules/menu_ui/menu_ui.install index a75a02c..c2aadce 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')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 03c5630..eacb7af 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -961,7 +961,7 @@ function node_form_system_themes_admin_form_submit($form, FormStateInterface $fo \Drupal::config('node.settings') ->set('use_admin_theme', $form_state->getValue('use_admin_theme')) ->save(); - \Drupal::service('router.builder')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** diff --git a/core/modules/search/src/Entity/SearchPage.php b/core/modules/search/src/Entity/SearchPage.php index 28aa0f8..b0eccde 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->routeBuilder()->setRebuildNeeded(); + $this->routeBuilderIndicator()->setRebuildNeeded(); } /** @@ -216,11 +216,11 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) /** * Wraps the route builder. * - * @return \Drupal\Core\Routing\RouteBuilderInterface + * @return \Drupal\Core\Routing\RouteBuilderIndicatorInterface * An object for state storage. */ - protected function routeBuilder() { - return \Drupal::service('router.builder'); + protected function routeBuilderIndicator() { + return \Drupal::service('router.builder_indicator'); } /** diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index b9f60fe..534b7b8 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -723,7 +723,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')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php index fb98842..5dee15e 100644 --- a/core/modules/system/src/Controller/ThemeController.php +++ b/core/modules/system/src/Controller/ThemeController.php @@ -9,7 +9,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ThemeHandlerInterface; -use Drupal\Core\Routing\RouteBuilderInterface; +use Drupal\Core\Routing\RouteBuilderIndicatorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -29,21 +29,21 @@ class ThemeController extends ControllerBase { /** * The route builder service. * - * @var \Drupal\Core\Routing\RouteBuilderInterface + * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface */ - protected $routeBuilder; + protected $routeBuilderIndicator; /** * Constructs a new ThemeController. * * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler. - * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder + * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder_indicator * The route builder. */ - public function __construct(ThemeHandlerInterface $theme_handler, RouteBuilderInterface $route_builder) { + public function __construct(ThemeHandlerInterface $theme_handler, RouteBuilderIndicatorInterface $route_builder_indicator) { $this->themeHandler = $theme_handler; - $this->routeBuilder = $route_builder; + $this->routeBuilderIndicator = $route_builder_indicator; } /** @@ -157,7 +157,7 @@ public function setDefaultTheme(Request $request) { // Set the default theme. $config->set('default', $theme)->save(); - $this->routeBuilder->setRebuildNeeded(); + $this->routeBuilderIndicator->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/user/user.module b/core/modules/user/user.module index de24373..61de86c 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1393,11 +1393,9 @@ function user_modules_installed($modules) { // Assign all available permissions to the administrator role. $rid = \Drupal::config('user.settings')->get('admin_role'); if ($rid) { - /** @var \Drupal\Core\Routing\RouteBuilderInterface $route_builder */ - $route_builder = \Drupal::service('router.builder'); // Some permissions call the url generator, so ensure that the routes are // up to date. - $route_builder->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); /** @var \Drupal\user\PermissionHandlerInterface $permission_handler */ $permission_handler = \Drupal::service('user.permissions'); $permissions = $permission_handler->getPermissions(); diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index f64ffb4..19d13c1 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -348,9 +348,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { // Rebuild the router case the view got enabled. if (!isset($this->original) || ($this->status() != $this->original->status())) { - /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */ - $router_builder = \Drupal::service('router.builder'); - $router_builder->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 24ef959..f9b947e 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -486,7 +486,7 @@ function views_invalidate_cache() { Cache::deleteTags(array('extension' => 'views')); // Set the menu as needed to be rebuilt. - \Drupal::service('router.builder')->setRebuildNeeded(); + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); $module_handler = \Drupal::moduleHandler(); diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index ff7c81d..22b1f25 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. + * The mocked route builder indicator. * - * @var \Drupal\Core\Routing\RouteBuilder|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $routeBuilder; + protected $routeBuilderIndicator; /** * The mocked info parser. @@ -109,9 +109,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->routeBuilder = $this->getMockBuilder('Drupal\Core\Routing\RouteBuilder') - ->disableOriginalConstructor() - ->getMock(); + $this->routeBuilderIndicator = $this->getMock('Drupal\Core\Routing\RouteBuilderIndicatorInterface'); $this->extensionDiscovery = $this->getMockBuilder('Drupal\Core\Extension\ExtensionDiscovery') ->disableOriginalConstructor() ->getMock(); @@ -119,7 +117,7 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); $logger = $this->getMock('Psr\Log\LoggerInterface'); - $this->themeHandler = new TestThemeHandler($this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilder, $this->extensionDiscovery); + $this->themeHandler = new TestThemeHandler($this->configFactory, $this->moduleHandler, $this->state, $this->infoParser, $logger, $this->cssCollectionOptimizer, $this->configInstaller, $this->configManager, $this->routeBuilderIndicator, $this->extensionDiscovery); $cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $this->getContainerWithCacheBins($cache_backend); diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php index aff98962..e28261b 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php @@ -74,9 +74,9 @@ class RouteBuilderTest extends UnitTestCase { /** * The key value store. * - * @var \Drupal\Core\State\StateInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $state; + protected $routeBuilderIndicator; protected function setUp() { $this->dumper = $this->getMock('Drupal\Core\Routing\MatcherDumperInterface'); @@ -87,9 +87,9 @@ protected function setUp() { $this->yamlDiscovery = $this->getMockBuilder('\Drupal\Component\Discovery\YamlDiscovery') ->disableOriginalConstructor() ->getMock(); - $this->state = $this->getMock('\Drupal\Core\State\StateInterface'); + $this->routeBuilderIndicator = $this->getMock('\Drupal\Core\Routing\RouteBuilderIndicatorInterface'); - $this->routeBuilder = new TestRouteBuilder($this->dumper, $this->lock, $this->dispatcher, $this->moduleHandler, $this->controllerResolver, $this->state); + $this->routeBuilder = new TestRouteBuilder($this->dumper, $this->lock, $this->dispatcher, $this->moduleHandler, $this->controllerResolver, $this->routeBuilderIndicator); $this->routeBuilder->setYamlDiscovery($this->yamlDiscovery); } @@ -106,9 +106,8 @@ public function testRebuildLockingUnlocking() { ->method('release') ->with('router_rebuild'); - $this->state->expects($this->once()) - ->method('delete') - ->with('router_rebuild_needed'); + $this->routeBuilderIndicator->expects($this->once()) + ->method('setRebuildDone'); $this->yamlDiscovery->expects($this->any()) ->method('findAll') @@ -257,17 +256,14 @@ public function testRebuildIfNecessary() { ->method('release') ->with('router_rebuild'); - $this->state->expects($this->once()) - ->method('set') - ->with('router_rebuild_needed'); + $this->routeBuilderIndicator->expects($this->once()) + ->method('setRebuildNeeded'); - $this->state->expects($this->once()) - ->method('delete') - ->with('router_rebuild_needed'); + $this->routeBuilderIndicator->expects($this->once()) + ->method('setRebuildDone'); - $this->state->expects($this->exactly(2)) - ->method('get') - ->with('router_rebuild_needed') + $this->routeBuilderIndicator->expects($this->exactly(2)) + ->method('isRebuildNeeded') ->will($this->onConsecutiveCalls(TRUE, FALSE)); $this->yamlDiscovery->expects($this->any())