diff --git a/core/modules/views/config/schema/views.display.schema.yml b/core/modules/views/config/schema/views.display.schema.yml index bb5ba8ae82..0735cadc36 100644 --- a/core/modules/views/config/schema/views.display.schema.yml +++ b/core/modules/views/config/schema/views.display.schema.yml @@ -68,9 +68,9 @@ views.display.page: menu_name: type: string label: 'Menu name' - admin_theme: + enforce_admin_theme: type: boolean - label: 'Use admin theme' + label: 'Enforce admin theme' views.display.block: type: views_display diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index b2ec8f25cd..9f064e588c 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -93,10 +93,10 @@ protected function getRoute($view_id, $display_id) { // Explicitly set HTML as the format for Page displays. $route->setRequirement('_format', 'html'); - // Add the _admin_route option only if 'admin_theme' display option is TRUE. - // Otherwise, let other modules or alters to make a decision. + // Add the _admin_route option only if 'enforce_admin_theme' display option + // is TRUE. Otherwise, let other modules or alters to make a decision. // @see \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes() - if ($this->getOption('admin_theme')) { + if ($this->getOption('enforce_admin_theme')) { $route->setOption('_admin_route', TRUE); } @@ -158,7 +158,7 @@ protected function defineOptions() { 'weight' => ['default' => 0], ], ]; - $options['admin_theme'] = ['default' => FALSE]; + $options['enforce_admin_theme'] = ['default' => FALSE]; return $options; } @@ -239,7 +239,7 @@ public function optionsSummary(&$categories, &$options) { $options['menu']['links']['tab_options'] = $this->t('Change settings for the parent menu'); } - if ($this->getOption('admin_theme')) { + if ($this->getOption('enforce_admin_theme')) { $options['path']['value'] .= ' ' . $this->t('(using admin theme)'); } } @@ -455,11 +455,11 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ]; break; case 'path': - $form['admin_theme'] = [ + $form['enforce_admin_theme'] = [ '#type' => 'checkbox', '#title' => $this->t('Enforce this page to be displayed in the admin theme'), '#description' => $this->t('Paths starting with /admin/ are always shown in the admin theme. If checked, pages on other paths are shown in the admin theme as well.'), - '#default_value' => $this->getOption('admin_theme'), + '#default_value' => $this->getOption('enforce_admin_theme'), ]; break; } @@ -512,7 +512,7 @@ public function submitOptionsForm(&$form, FormStateInterface $form_state) { $this->setOption('tab_options', $form_state->getValue('tab_options')); break; case 'path': - $this->setOption('admin_theme', $form_state->getValue('admin_theme')); + $this->setOption('enforce_admin_theme', $form_state->getValue('enforce_admin_theme')); break; } } diff --git a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php index bc4c30aa7b..63569320f7 100644 --- a/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php @@ -163,7 +163,7 @@ public function testAdminTheme() { $this->assertSession()->responseNotContains('seven/css/base/elements.css'); $view = $this->config('views.view.test_page_display'); - $view->set('display.page_3.display_options.admin_theme', TRUE)->save(); + $view->set('display.page_3.display_options.enforce_admin_theme', TRUE)->save(); $this->container->get('router.builder')->rebuild(); // Check that the page was served with the administrative theme. diff --git a/core/modules/views/tests/src/Functional/Update/EnforceAdminThemeOptionUpdateTest.php b/core/modules/views/tests/src/Functional/Update/EnforceAdminThemeOptionUpdateTest.php index 12117aaa4a..83f4f4d8fa 100644 --- a/core/modules/views/tests/src/Functional/Update/EnforceAdminThemeOptionUpdateTest.php +++ b/core/modules/views/tests/src/Functional/Update/EnforceAdminThemeOptionUpdateTest.php @@ -9,7 +9,7 @@ * * @group views */ -class AdminThemeOptionUpdateTest extends UpdatePathTestBase { +class EnforceAdminThemeOptionUpdateTest extends UpdatePathTestBase { /** * {@inheritdoc} @@ -21,22 +21,25 @@ protected function setDatabaseDumpFiles() { } /** - * Tests the updating of views dependencies to image styles. + * Tests views_post_update_enforce_admin_theme(). + * + * @see views_post_update_enforce_admin_theme() */ - public function testUpdateAdminThemeOption() { - // Check that admin_theme option doesn't exist in 'content' view. + public function testViewsPostUpdateEnforceAdminTheme() { $options = $this->config('views.view.content') ->get('display.page_1.display_options'); - $this->assertArrayNotHasKey('admin_theme', $options); + // Check that enforce_admin_theme option doesn't exist in 'content' view. + $this->assertArrayNotHasKey('enforce_admin_theme', $options); // Run updates. $this->runUpdates(); - // Check that admin_theme option was added in 'content' view and is TRUE. $options = $this->config('views.view.content') ->get('display.page_1.display_options'); - $this->assertArrayHasKey('admin_theme', $options); - $this->assertFalse($options['admin_theme']); + // Check that enforce_admin_theme option was added in 'content'. + $this->assertArrayHasKey('enforce_admin_theme', $options); + // Check that enforce_admin_theme option is TRUE. + $this->assertFalse($options['enforce_admin_theme']); } } diff --git a/core/modules/views/views.post_update.php b/core/modules/views/views.post_update.php index ec722f4359..a277bfb7e2 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -260,14 +260,14 @@ function views_post_update_entity_link_url() { /** * Fix views with page display administrative theme option. */ -function views_post_update_admin_theme() { +function views_post_update_enforce_admin_theme() { $config_factory = \Drupal::configFactory(); foreach ($config_factory->listAll('views.view.') as $name) { $view = $config_factory->getEditable($name); foreach ($view->get('display') as $display_id => $display) { // Deal only with page displays. if ($display['display_plugin'] == 'page') { - $trail = "display.$display_id.display_options.admin_theme"; + $trail = "display.$display_id.display_options.enforce_admin_theme"; $view->set($trail, FALSE)->save(); } }