diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 5a13735..805457c 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -99,8 +99,8 @@ function drupal_theme_initialize() { $themes = list_themes(); // @todo Let the theme.negotiator listen to the kernel request event. - $request = Drupal::request(); - $theme = Drupal::service('theme.negotiator')->determineActiveTheme($request) ?: 'stark'; + $request = \Drupal::request(); + $theme = \Drupal::service('theme.negotiator')->determineActiveTheme($request) ?: 'stark'; // Store the identifier for retrieving theme settings with. $theme_key = $theme; @@ -115,7 +115,7 @@ function drupal_theme_initialize() { _drupal_theme_initialize($themes[$theme], array_reverse($base_theme)); // Themes can have alter functions, so reset the drupal_alter() cache. - Drupal::moduleHandler()->resetImplementations(); + \Drupal::moduleHandler()->resetImplementations(); } /** diff --git a/core/lib/Drupal/Core/Theme/DefaultNegotiator.php b/core/lib/Drupal/Core/Theme/DefaultNegotiator.php index f155b0d..d596678 100644 --- a/core/lib/Drupal/Core/Theme/DefaultNegotiator.php +++ b/core/lib/Drupal/Core/Theme/DefaultNegotiator.php @@ -16,6 +16,13 @@ class DefaultNegotiator implements ThemeNegotiatorInterface { /** + * The system theme config object. + * + * @var \Drupal\Core\Config\Config + */ + protected $config; + + /** * Constructs a DefaultNegotiator object. * * @param \Drupal\Core\Config\ConfigFactory $config_factory diff --git a/core/modules/block/lib/Drupal/block/Theme/AdminDemoNegotiator.php b/core/modules/block/lib/Drupal/block/Theme/AdminDemoNegotiator.php index 2d9d351..d3dcb33 100644 --- a/core/modules/block/lib/Drupal/block/Theme/AdminDemoNegotiator.php +++ b/core/modules/block/lib/Drupal/block/Theme/AdminDemoNegotiator.php @@ -27,4 +27,4 @@ public function determineActiveTheme(Request $request) { } } -} +} diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php index ab3f913..101b745 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php @@ -38,7 +38,7 @@ function setUp() { // Enable the extra type module for searching. \Drupal::config('search.settings')->set('active_plugins', array('node_search', 'user_search', 'search_extra_type_search'))->save(); - \Drupal::state()->set('menu_rebuild_needed', TRUE); + \Drupal::service('router.builder')->rebuild(); } function testSearchPageHook() { diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index 1fdb3ba..b747d79 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -145,6 +145,7 @@ function testShortcutLinkDelete() { */ function testNoShortcutLink() { // Change to a theme that displays shortcuts. + theme_enable(array('seven')); \Drupal::config('system.theme') ->set('default', 'seven') ->save(); @@ -157,8 +158,9 @@ function testNoShortcutLink() { $this->assertNoRaw('add-shortcut', 'Add to shortcuts link was not shown on a page the user does not have access to.'); // Verify that the testing mechanism works by verifying the shortcut - // link appears on admin/content. - $this->drupalGet('admin/content'); + // link appears on admin/people. + $this->drupalGet('admin/people'); $this->assertRaw('add-shortcut', 'Add to shortcuts link was shown on a page the user does have access to.'); } + } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php index 06088ef..e0bdb31 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php @@ -69,7 +69,7 @@ function setUp() { } // Create users. - $this->admin_user = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview')); + $this->admin_user = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users')); $this->shortcut_user = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets')); // Create a node. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php index 9a13acb..554450a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php @@ -178,7 +178,7 @@ function testThemeSettings() { * Test the administration theme functionality. */ function testAdministrationTheme() { - theme_enable(array('seven')); + theme_enable(array('bartik', 'seven')); // Enable an administration theme and show it on the node admin pages. $edit = array( diff --git a/core/modules/system/lib/Drupal/system/Theme/AdminNegotiator.php b/core/modules/system/lib/Drupal/system/Theme/AdminNegotiator.php index 2bd4bd5..72359ea 100644 --- a/core/modules/system/lib/Drupal/system/Theme/AdminNegotiator.php +++ b/core/modules/system/lib/Drupal/system/Theme/AdminNegotiator.php @@ -68,4 +68,4 @@ public function determineActiveTheme(Request $request) { } } -} +} diff --git a/core/modules/system/lib/Drupal/system/Theme/BatchNegotiator.php b/core/modules/system/lib/Drupal/system/Theme/BatchNegotiator.php index e6694e9..a10374d 100644 --- a/core/modules/system/lib/Drupal/system/Theme/BatchNegotiator.php +++ b/core/modules/system/lib/Drupal/system/Theme/BatchNegotiator.php @@ -51,4 +51,4 @@ public function determineActiveTheme(Request $request) { } } -} +} diff --git a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php new file mode 100644 index 0000000..4bb3595 --- /dev/null +++ b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/EventSubscriber/ActiveTrailSubscriber.php @@ -0,0 +1,68 @@ +state = $state; + } + + /** + * Tracks the active trail. + * + * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event + * The event to process. + */ + public function onKernelRequest(GetResponseEvent $event) { + // When requested by one of the MenuTrailTestCase tests, record the initial + // active trail during Drupal's bootstrap (before the user is redirected to + // a custom 403 or 404 page). + if (!$this->trail && $this->state->get('menu_test.record_active_trail') ?: FALSE) { + $this->trail = menu_get_active_trail(); + $this->state->set('menu_test.active_trail_initial', $this->trail); + } + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[KernelEvents::REQUEST][] = array('onKernelRequest'); + return $events; + } + +} diff --git a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Theme/TestThemeNegotiator.php b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Theme/TestThemeNegotiator.php index eb4f356..b324d8d 100644 --- a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Theme/TestThemeNegotiator.php +++ b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Theme/TestThemeNegotiator.php @@ -40,4 +40,4 @@ public function determineActiveTheme(Request $request) { // causes the page to correctly fall back on using the main site theme. } -} +} diff --git a/core/modules/system/tests/modules/menu_test/menu_test.services.yml b/core/modules/system/tests/modules/menu_test/menu_test.services.yml index b52f8cf..3de0169 100644 --- a/core/modules/system/tests/modules/menu_test/menu_test.services.yml +++ b/core/modules/system/tests/modules/menu_test/menu_test.services.yml @@ -4,6 +4,12 @@ services: tags: - { name: event_subscriber } + menu_test.active_trail_subscriber: + class: Drupal\menu_test\EventSubscriber\ActiveTrailSubscriber + arguments: ['@state'] + tags: + - { name: event_subscriber } + theme.negotiator.test_theme: class: Drupal\menu_test\Theme\TestThemeNegotiator tags: diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/Theme/CustomThemeNegotiator.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/Theme/CustomThemeNegotiator.php index 6ca1b71..9c0396e 100644 --- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/Theme/CustomThemeNegotiator.php +++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/Theme/CustomThemeNegotiator.php @@ -26,4 +26,4 @@ public function determineActiveTheme(Request $request) { } } -} +} diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php index 452e33f..ee8cc38 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/ThemeTest.php @@ -25,11 +25,11 @@ function setUp() { // Make sure we are using distinct default and administrative themes for // the duration of these tests. + theme_enable(array('bartik', 'seven')); \Drupal::config('system.theme') ->set('default', 'bartik') + ->set('admin', 'seven') ->save(); - theme_enable(array('seven')); - \Drupal::config('system.theme')->set('admin', 'seven')->save(); // Create and log in as a user who has permission to add and edit taxonomy // terms and view the administrative theme. diff --git a/core/modules/user/user.info.yml b/core/modules/user/user.info.yml index 4af3313..45a421a 100644 --- a/core/modules/user/user.info.yml +++ b/core/modules/user/user.info.yml @@ -6,5 +6,3 @@ version: VERSION core: 8.x required: true configure: user.admin_index -dependencies: - - field