diff --git a/core/core.services.yml b/core/core.services.yml index d52e1fabe2a5dbb0df69047a5fdcc521e8ed6d0b..6316b1f25c2a4243d080e1703f14026901315be2 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,9 +529,12 @@ 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', '@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 727ab680c1a1fd5e908ce322cbe7675878c8d69d..fe6c0809ffb2af55a5d6d08948ece83b539e1ab1 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 694185f957d135cdfa26b124ab74e93b99f8b889..a316f36e15204cf9056848692b0a0c8910c75a6f 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -13,8 +13,8 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigInstallerInterface; use Drupal\Core\Config\ConfigManagerInterface; +use Drupal\Core\Routing\RouteBuilderIndicatorInterface; use Drupal\Core\State\StateInterface; -use Drupal\Core\Routing\RouteBuilder; 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\RouteBuilder + * @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\RouteBuilder $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, RouteBuilder $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/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index 5bea0a56db4dddb01c3558b3249d47c4c073f8d9..e201b4296807abfb698b76559e22cbd097948b8e 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -58,6 +58,13 @@ class RouteBuilder implements RouteBuilderInterface { */ protected $moduleHandler; + /** + * The route builder indicator. + * + * @var \Drupal\Core\Routing\RouteBuilderIndicatorInterface + */ + protected $routeBuilderIndicator; + /** * The controller resolver. * @@ -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 0000000000000000000000000000000000000000..5f0612082293862e8c32391cc3f5cd9c626444af --- /dev/null +++ b/core/lib/Drupal/Core/Routing/RouteBuilderIndicator.php @@ -0,0 +1,55 @@ +<?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 new file mode 100644 index 0000000000000000000000000000000000000000..68ce5b800fe6ab6db00ce8655e505b42e59335d5 --- /dev/null +++ b/core/lib/Drupal/Core/Routing/RouteBuilderIndicatorInterface.php @@ -0,0 +1,39 @@ +<?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/RouteBuilderInterface.php b/core/lib/Drupal/Core/Routing/RouteBuilderInterface.php index 4d5b4b5b80983018cd7a2d326b727edd86667ddf..849d4ad07f7ca91f2aad1b68d72604bf81c5e801 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilderInterface.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilderInterface.php @@ -9,8 +9,6 @@ interface RouteBuilderInterface { - const REBUILD_NEEDED = 'router_rebuild_needed'; - /** * Rebuilds the route info and dumps to dumper. * diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 81473bf11a64757697a6012ced517d67c5122bdc..7636150c05259397cb9a6985e1e852fa8bca1105 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 3f6d9dae21a37d0a6e29e4afc042ca9e4bca9994..f4e61a8bbb828f4f7964113da0c58b917e4d8f86 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 246cf3b594d9ab9dd8561e8ef24c59669fefde8a..c11a6de00bba430706cfa14e25d840da3ceb0eb9 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 a75a02ca6daab5794e059885c0da0582a7279f4b..c2aadce1b1483b64c8ced637fcb7890c03ea16e6 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 03c56308d1be2827e8d600355267dd3dcf6d0df1..eacb7afd1474fdb4195d49918e6ad3f64bfa6731 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 28aa0f812a7b7bc3a4e85998bba7ca533c92638e..b0eccde009ab27bf3b9616f9630ee1cf9d86f359 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 b9f60fe3204f9fcaee4732290420d1653e806250..534b7b88019a3c99861c3db8afab0052fe31a45f 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 fb988425559d40a6cb0fcc34211ab3461c863d79..3bb6d316895b3c71fbb83660d6bd2e0385468ce8 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; } /** @@ -52,7 +52,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') + $container->get('router.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 de24373b14e151c5465ce0dcfb83e07c276b50b0..61de86c6c985be8bde647828a887a63d62a3beaf 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 f64ffb4c1bf38c7efe11be2e0960c709a9241a51..19d13c1cde4d6e205e340acda091a337757655d0 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 24ef95921ad069a832cafa012717423308f69a74..f9b947e441cf38e327f7f7db30ac3f0acdd6f6df 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 ff7c81d63072e63f0afc18740f6eb526ed463d19..22b1f25653794c70653944806528ce84b354faf6 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 aff989621ba449856a72ee904403044543e09ae2..e28261b8099930bae5a314544d6ae17b4dc9cb5e 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())