From c12498bd9eb37d215a4576b430c46ae3cfcd2538 Mon Sep 17 00:00:00 2001 From: catch Date: Fri, 12 Jul 2019 14:15:04 +0100 Subject: [PATCH] Issue #2776031 by fgm, andypost, voleger, yogeshmpawar, Berdir, joachim: Properly deprecate ThemeHandlerInterface install() and uninstall() also replace usage --- core/includes/install.core.inc | 2 +- .../lib/Drupal/Core/Config/ConfigImporter.php | 2 +- .../Drupal/Core/Extension/ThemeHandler.php | 2 + .../Core/Extension/ThemeHandlerInterface.php | 13 +++--- core/lib/Drupal/Core/Render/theme.api.php | 4 +- .../src/Functional/BlockAdminThemeTest.php | 4 +- .../tests/src/Functional/BlockDemoTest.php | 2 +- .../src/Functional/BlockHiddenRegionTest.php | 2 +- .../block/tests/src/Functional/BlockTest.php | 12 ++--- .../tests/src/Functional/BlockUiTest.php | 4 +- .../Functional/NonDefaultBlockAdminTest.php | 2 +- .../tests/src/Kernel/BlockStorageUnitTest.php | 2 +- .../src/Kernel/NewDefaultThemeBlocksTest.php | 7 +-- .../src/Functional/BlockContentTypeTest.php | 2 +- .../src/Kernel/BreakpointDiscoveryTest.php | 2 +- .../src/Functional/CKEditorLoadingTest.php | 9 ++-- .../tests/src/Kernel/CKEditorTest.php | 2 +- .../src/Functional/ColorConfigSchemaTest.php | 2 +- .../src/Functional/ColorSafePreviewTest.php | 2 +- .../color/tests/src/Functional/ColorTest.php | 2 +- .../tests/src/Functional/CommentLinksTest.php | 2 +- .../src/Functional/ConfigImportUITest.php | 2 +- .../src/Functional/ConfigInstallWebTest.php | 2 +- .../field/tests/src/Kernel/DisplayApiTest.php | 2 +- .../EntityReferenceFormatterTest.php | 2 +- .../src/Functional/MultipleFileUploadTest.php | 2 +- .../tests/src/Functional/HelpTopicTest.php | 2 +- .../Functional/HelpTopicTranslationTest.php | 2 +- .../src/Kernel/Views/HistoryTimestampTest.php | 2 +- .../LayoutBuilderCompatibilityTestBase.php | 2 +- .../MediaSourceOEmbedVideoTest.php | 2 +- .../MenuLinkContentTranslationUITest.php | 2 +- .../src/Functional/NodeTranslationUITest.php | 2 +- .../src/Functional/StandardProfileTest.php | 2 +- .../src/Kernel/Field/NumberFieldRdfaTest.php | 8 ++-- .../src/Functional/ShortcutLinksTest.php | 6 +-- .../src/Functional/StatisticsAttachedTest.php | 2 +- .../system/src/Controller/ThemeController.php | 22 +++++++-- core/modules/system/system.install | 3 +- .../tests/src/Functional/Batch/PageTest.php | 2 +- .../tests/src/Functional/Common/AlterTest.php | 2 +- .../src/Functional/Menu/MenuRouterTest.php | 12 +++-- .../Functional/System/SiteMaintenanceTest.php | 2 +- .../tests/src/Functional/System/ThemeTest.php | 24 +++++----- .../Functional/Theme/EngineNyanCatTest.php | 2 +- .../src/Functional/Theme/EngineTwigTest.php | 2 +- .../Theme/EntityFilteringThemeTest.php | 2 +- .../src/Functional/Theme/ThemeInfoTest.php | 12 ++--- .../Theme/ThemeSuggestionsAlterTest.php | 2 +- .../tests/src/Functional/Theme/ThemeTest.php | 2 +- .../Functional/Theme/TwigDebugMarkupTest.php | 2 +- .../Functional/Theme/TwigExtensionTest.php | 2 +- .../Theme/TwigRegistryLoaderTest.php | 2 +- .../src/Functional/Theme/TwigSettingsTest.php | 4 +- .../src/Functional/Theme/TwigTransTest.php | 2 +- .../FunctionalJavascript/FrameworkTest.php | 2 +- .../ThemeFormSettingsTest.php | 2 +- .../Migrate/d7/MigrateThemeSettingsTest.php | 6 +-- .../tests/src/Kernel/Theme/FunctionsTest.php | 2 +- .../tests/src/Kernel/Theme/ThemeTest.php | 4 +- .../src/Kernel/Theme/TwigNamespaceTest.php | 2 +- .../tests/src/Functional/ThemeTest.php | 2 +- .../tests/src/Functional/TourTestBasic.php | 2 +- .../src/Functional/UpdateContribTest.php | 4 +- .../user/tests/src/Kernel/UserFieldsTest.php | 2 +- .../Plugin/ExposedFormCheckboxesTest.php | 4 +- .../src/Functional/ViewsEscapingTest.php | 2 +- .../Functional/ViewsNoResultsBehaviorTest.php | 6 +-- .../Functional/ViewsThemeIntegrationTest.php | 2 +- .../src/Kernel/Plugin/DisplayPageTest.php | 2 +- .../tests/src/Kernel/ViewsPreprocessTest.php | 2 +- .../src/Functional/CustomBooleanTest.php | 2 +- .../Core/Bootstrap/GetFilenameTest.php | 2 +- .../Core/Config/DefaultConfigTest.php | 2 +- .../Condition/CurrentThemeConditionTest.php | 2 +- .../Core/Render/Element/TableTest.php | 2 +- .../Render/ElementInfoIntegrationTest.php | 2 +- .../KernelTests/Core/Theme/MessageTest.php | 2 +- .../KernelTests/Core/Theme/RegistryTest.php | 8 ++-- .../Core/Theme/StableThemeTest.php | 12 ++--- .../Core/Theme/ThemeHandlerLegacyTest.php | 46 +++++++++++++++++++ .../Core/Theme/ThemeInstallerTest.php | 18 ++++---- .../Core/Theme/ThemeSettingsTest.php | 10 ++-- .../Core/Theme/TwigWhiteListTest.php | 2 +- 84 files changed, 223 insertions(+), 157 deletions(-) create mode 100644 core/tests/Drupal/KernelTests/Core/Theme/ThemeHandlerLegacyTest.php diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index d788288a3a72..12516b4cf602 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1641,7 +1641,7 @@ function install_core_entity_type_definitions() { function install_profile_themes(&$install_state) { // Install the themes specified by the installation profile. $themes = $install_state['profile_info']['themes']; - \Drupal::service('theme_handler')->install($themes); + \Drupal::service('theme_installer')->install($themes); // Ensure that the install profile's theme is used. // @see _drupal_maintenance_theme() diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index 91317c27f8a5..03ad2b2d422f 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -829,7 +829,7 @@ class ConfigImporter { $this->configManager->getConfigFactory()->reset('system.theme'); $this->processedSystemTheme = TRUE; } - $this->themeHandler->$op([$name]); + \Drupal::service('theme_installer')->$op([$name]); } $this->setProcessedExtension($type, $op, $name); diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index a5dd850d88ee..e6f1ea0a4d26 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -82,6 +82,7 @@ class ThemeHandler implements ThemeHandlerInterface { public function install(array $theme_list, $install_dependencies = TRUE) { // We keep the old install() method as BC layer but redirect directly to the // theme installer. + @trigger_error('\Drupal\Core\Extension\ThemeHandlerInterface::install() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\ThemeInstallerInterface::install() instead. See https://www.drupal.org/node/3017233', E_USER_DEPRECATED); return \Drupal::service('theme_installer')->install($theme_list, $install_dependencies); } @@ -91,6 +92,7 @@ class ThemeHandler implements ThemeHandlerInterface { public function uninstall(array $theme_list) { // We keep the old uninstall() method as BC layer but redirect directly to // the theme installer. + @trigger_error('\Drupal\Core\Extension\ThemeHandlerInterface::uninstall() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\ThemeInstallerInterface::uninstall() instead. See https://www.drupal.org/node/3017233', E_USER_DEPRECATED); \Drupal::service('theme_installer')->uninstall($theme_list); } diff --git a/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php b/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php index 97f103ad704a..8d0f21d85898 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandlerInterface.php @@ -23,10 +23,11 @@ interface ThemeHandlerInterface { * @throws \Drupal\Core\Extension\ExtensionNameLengthException * Thrown when the theme name is to long. * - * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0. + * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. * Use the theme_installer service instead. * - * @see \Drupal\Core\Extension\ThemeInstallerInterface::install + * @see https://www.drupal.org/node/3017233 + * @see \Drupal\Core\Extension\ThemeInstallerInterface::install() */ public function install(array $theme_list, $install_dependencies = TRUE); @@ -42,12 +43,12 @@ interface ThemeHandlerInterface { * @throws \Drupal\Core\Extension\Exception\UninstalledExtensionException * Thrown when you try to uninstall a theme that wasn't installed. * - * @see hook_themes_uninstalled() - * - * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0. + * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. * Use the theme_installer service instead. * - * @see \Drupal\Core\Extension\ThemeInstallerInterface::uninstall + * @see https://www.drupal.org/node/3017233 + * @see hook_themes_uninstalled() + * @see \Drupal\Core\Extension\ThemeInstallerInterface::uninstall() */ public function uninstall(array $theme_list); diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php index 18e380f3cc3e..32ff6774af0c 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -725,7 +725,7 @@ function hook_theme_suggestions_HOOK_alter(array &$suggestions, array $variables * @param array $theme_list * Array containing the names of the themes being installed. * - * @see \Drupal\Core\Extension\ThemeHandler::install() + * @see \Drupal\Core\Extension\ThemeInstallerInterface::install() */ function hook_themes_installed($theme_list) { foreach ($theme_list as $theme) { @@ -739,7 +739,7 @@ function hook_themes_installed($theme_list) { * @param array $themes * Array containing the names of the themes being uninstalled. * - * @see \Drupal\Core\Extension\ThemeHandler::uninstall() + * @see \Drupal\Core\Extension\ThemeInstallerInterface::uninstall() */ function hook_themes_uninstalled(array $themes) { // Remove some state entries depending on the theme. diff --git a/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php b/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php index 88f35e4b09e1..9811b2169497 100644 --- a/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php +++ b/core/modules/block/tests/src/Functional/BlockAdminThemeTest.php @@ -32,7 +32,7 @@ class BlockAdminThemeTest extends BrowserTestBase { $this->assertResponse(403); // Install admin theme and confirm that tab is accessible. - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); $edit['admin_theme'] = 'bartik'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/list/bartik'); @@ -53,7 +53,7 @@ class BlockAdminThemeTest extends BrowserTestBase { $this->drupalLogin($admin_user); // Install admin theme and confirm that tab is accessible. - \Drupal::service('theme_handler')->install(['seven']); + \Drupal::service('theme_installer')->install(['seven']); $edit['admin_theme'] = 'seven'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); diff --git a/core/modules/block/tests/src/Functional/BlockDemoTest.php b/core/modules/block/tests/src/Functional/BlockDemoTest.php index 884b587a11a0..0c8b117c61d4 100644 --- a/core/modules/block/tests/src/Functional/BlockDemoTest.php +++ b/core/modules/block/tests/src/Functional/BlockDemoTest.php @@ -47,7 +47,7 @@ class BlockDemoTest extends BrowserTestBase { foreach ($themes as $theme) { // Install theme. - $this->container->get('theme_handler')->install([$theme]); + $this->container->get('theme_installer')->install([$theme]); // Confirm access to the block demo page for the theme. $this->drupalGet('admin/structure/block/demo/' . $theme); $this->assertResponse(200); diff --git a/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php b/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php index c51551521ab9..fe96520eae75 100644 --- a/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php +++ b/core/modules/block/tests/src/Functional/BlockHiddenRegionTest.php @@ -53,7 +53,7 @@ class BlockHiddenRegionTest extends BrowserTestBase { $theme = 'block_test_theme'; // We need to install a non-hidden theme so that there is more than one // local task. - \Drupal::service('theme_handler')->install([$theme, 'stark']); + \Drupal::service('theme_installer')->install([$theme, 'stark']); $this->config('system.theme') ->set('default', $theme) ->save(); diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php index 3ee8203984df..1d653491b856 100644 --- a/core/modules/block/tests/src/Functional/BlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockTest.php @@ -244,7 +244,7 @@ class BlockTest extends BlockTestBase { */ public function testBlockThemeSelector() { // Install all themes. - \Drupal::service('theme_handler')->install(['bartik', 'seven', 'stark']); + \Drupal::service('theme_installer')->install(['bartik', 'seven', 'stark']); $theme_settings = $this->config('system.theme'); foreach (['bartik', 'seven', 'stark'] as $theme) { $this->drupalGet('admin/structure/block/list/' . $theme); @@ -275,7 +275,7 @@ class BlockTest extends BlockTestBase { $this->drupalPlaceBlock('local_tasks_block'); // Explicitly set the default and admin themes. $theme = 'block_test_specialchars_theme'; - \Drupal::service('theme_handler')->install([$theme]); + \Drupal::service('theme_installer')->install([$theme]); \Drupal::service('router.builder')->rebuild(); $this->drupalGet('admin/structure/block'); $this->assertEscaped('<"Cat" & \'Mouse\'>'); @@ -484,17 +484,17 @@ class BlockTest extends BlockTestBase { * Tests that uninstalling a theme removes its block configuration. */ public function testUninstallTheme() { - /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ - $theme_handler = \Drupal::service('theme_handler'); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = \Drupal::service('theme_installer'); - $theme_handler->install(['seven']); + $theme_installer->install(['seven']); $this->config('system.theme')->set('default', 'seven')->save(); $block = $this->drupalPlaceBlock('system_powered_by_block', ['theme' => 'seven', 'region' => 'help']); $this->drupalGet(''); $this->assertText('Powered by Drupal'); $this->config('system.theme')->set('default', 'classy')->save(); - $theme_handler->uninstall(['seven']); + $theme_installer->uninstall(['seven']); // Ensure that the block configuration does not exist anymore. $this->assertIdentical(NULL, Block::load($block->id())); diff --git a/core/modules/block/tests/src/Functional/BlockUiTest.php b/core/modules/block/tests/src/Functional/BlockUiTest.php index c0056fac3578..f7fc5d52447c 100644 --- a/core/modules/block/tests/src/Functional/BlockUiTest.php +++ b/core/modules/block/tests/src/Functional/BlockUiTest.php @@ -84,11 +84,11 @@ class BlockUiTest extends BrowserTestBase { $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [':title' => 'Highlighted']); $this->assertTrue(!empty($elements), 'Block demo regions are shown.'); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->drupalGet('admin/structure/block/demo/test_theme'); $this->assertEscaped('Test theme'); - \Drupal::service('theme_handler')->install(['stable']); + \Drupal::service('theme_installer')->install(['stable']); $this->drupalGet('admin/structure/block/demo/stable'); $this->assertResponse(404, 'Hidden themes that are not the default theme are not supported by the block demo screen'); } diff --git a/core/modules/block/tests/src/Functional/NonDefaultBlockAdminTest.php b/core/modules/block/tests/src/Functional/NonDefaultBlockAdminTest.php index 7b7927de20c1..43efccb991ce 100644 --- a/core/modules/block/tests/src/Functional/NonDefaultBlockAdminTest.php +++ b/core/modules/block/tests/src/Functional/NonDefaultBlockAdminTest.php @@ -34,7 +34,7 @@ class NonDefaultBlockAdminTest extends BrowserTestBase { $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']); $this->drupalLogin($admin_user); $new_theme = 'bartik'; - \Drupal::service('theme_handler')->install([$new_theme]); + \Drupal::service('theme_installer')->install([$new_theme]); $this->drupalGet('admin/structure/block/list/' . $new_theme); $this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.'); } diff --git a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php index cfe9d1b0d889..4b13f9c6dd5e 100644 --- a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +++ b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php @@ -143,7 +143,7 @@ class BlockStorageUnitTest extends KernelTestBase { * Tests the installation of default blocks. */ public function testDefaultBlocks() { - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $entities = $this->controller->loadMultiple(); $this->assertTrue(empty($entities), 'There are no blocks initially.'); diff --git a/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php b/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php index b5ee56cf2ecd..9e415f712a8a 100644 --- a/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php +++ b/core/modules/block/tests/src/Kernel/NewDefaultThemeBlocksTest.php @@ -26,7 +26,8 @@ class NewDefaultThemeBlocksTest extends KernelTestBase { * Check the enabled Bartik blocks are correctly copied over. */ public function testNewDefaultThemeBlocks() { - $theme_handler = $this->container->get('theme_handler'); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = $this->container->get('theme_installer'); $default_theme = $this->config('system.theme')->get('default'); // Add two instances of the user login block. @@ -47,7 +48,7 @@ class NewDefaultThemeBlocksTest extends KernelTestBase { // The new theme is different from the previous default theme. $this->assertNotEquals($new_theme, $default_theme); - $theme_handler->install([$new_theme]); + $theme_installer->install([$new_theme]); $this->config('system.theme') ->set('default', $new_theme) ->save(); @@ -74,7 +75,7 @@ class NewDefaultThemeBlocksTest extends KernelTestBase { // Install a hidden base theme and ensure blocks are not copied. $base_theme = 'test_basetheme'; - $theme_handler->install([$base_theme]); + $theme_installer->install([$base_theme]); $new_blocks = $block_storage->getQuery() ->condition('theme', $base_theme) ->execute(); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index e5b8660b3dd8..bd3695cae398 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -192,7 +192,7 @@ class BlockContentTypeTest extends BlockContentTestBase { ->getStorage('block_content'); // Install all themes. - \Drupal::service('theme_handler')->install(['bartik', 'seven', 'stark']); + \Drupal::service('theme_installer')->install(['bartik', 'seven', 'stark']); $theme_settings = $this->config('system.theme'); foreach (['bartik', 'seven', 'stark'] as $default_theme) { // Change the default theme. diff --git a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php index dc8175787b49..884c5a2bda44 100644 --- a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php +++ b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php @@ -20,7 +20,7 @@ class BreakpointDiscoveryTest extends KernelTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['breakpoint_theme_test']); + \Drupal::service('theme_installer')->install(['breakpoint_theme_test']); } /** diff --git a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php index cad0947dcf99..d56919636c6d 100644 --- a/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php +++ b/core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php @@ -204,9 +204,10 @@ class CKEditorLoadingTest extends BrowserTestBase { * Tests loading of theme's CKEditor stylesheets defined in the .info file. */ public function testExternalStylesheets() { - $theme_handler = \Drupal::service('theme_handler'); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = \Drupal::service('theme_installer'); // Case 1: Install theme which has an absolute external CSS URL. - $theme_handler->install(['test_ckeditor_stylesheets_external']); + $theme_installer->install(['test_ckeditor_stylesheets_external']); $this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_external')->save(); $expected = [ 'https://fonts.googleapis.com/css?family=Open+Sans', @@ -214,7 +215,7 @@ class CKEditorLoadingTest extends BrowserTestBase { $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_external')); // Case 2: Install theme which has an external protocol-relative CSS URL. - $theme_handler->install(['test_ckeditor_stylesheets_protocol_relative']); + $theme_installer->install(['test_ckeditor_stylesheets_protocol_relative']); $this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_protocol_relative')->save(); $expected = [ '//fonts.googleapis.com/css?family=Open+Sans', @@ -222,7 +223,7 @@ class CKEditorLoadingTest extends BrowserTestBase { $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_protocol_relative')); // Case 3: Install theme which has a relative CSS URL. - $theme_handler->install(['test_ckeditor_stylesheets_relative']); + $theme_installer->install(['test_ckeditor_stylesheets_relative']); $this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_relative')->save(); $expected = [ 'core/modules/system/tests/themes/test_ckeditor_stylesheets_relative/css/yokotsoko.css', diff --git a/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php b/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php index 6ff5d20e6a60..b216ecb2488c 100644 --- a/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php +++ b/core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php @@ -272,7 +272,7 @@ class CKEditorTest extends KernelTestBase { $this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly while a CKEditorPluginInterface implementation exists.'); // Enable the Bartik theme, which specifies a CKEditor stylesheet. - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); $this->config('system.theme')->set('default', 'bartik')->save(); $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/base/elements.css')); $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/components/captions.css')); diff --git a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php index f93f3587b1fe..2fa95d1478d2 100644 --- a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php +++ b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php @@ -30,7 +30,7 @@ class ColorConfigSchemaTest extends BrowserTestBase { */ protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); // Create user. $this->adminUser = $this->drupalCreateUser(['administer themes']); diff --git a/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php b/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php index 9f6914c996c0..fa4e81ecf2df 100644 --- a/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php +++ b/core/modules/color/tests/src/Functional/ColorSafePreviewTest.php @@ -41,7 +41,7 @@ class ColorSafePreviewTest extends BrowserTestBase { */ public function testColorPreview() { // Install the color test theme. - \Drupal::service('theme_handler')->install(['color_test_theme']); + \Drupal::service('theme_installer')->install(['color_test_theme']); $this->drupalLogin($this->bigUser); // Markup is being printed from a HTML file located in: diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php index de3ab691607d..5e1bf96eccc5 100644 --- a/core/modules/color/tests/src/Functional/ColorTest.php +++ b/core/modules/color/tests/src/Functional/ColorTest.php @@ -65,7 +65,7 @@ class ColorTest extends BrowserTestBase { 'scheme_color' => '#3b3b3b', ], ]; - \Drupal::service('theme_handler')->install(array_keys($this->themes)); + \Drupal::service('theme_installer')->install(array_keys($this->themes)); // Array filled with valid and not valid color values. $this->colorTests = [ diff --git a/core/modules/comment/tests/src/Functional/CommentLinksTest.php b/core/modules/comment/tests/src/Functional/CommentLinksTest.php index 4ce4e1c1959a..0b9c4181a19b 100644 --- a/core/modules/comment/tests/src/Functional/CommentLinksTest.php +++ b/core/modules/comment/tests/src/Functional/CommentLinksTest.php @@ -43,7 +43,7 @@ class CommentLinksTest extends CommentTestBase { */ public function testCommentLinks() { // Bartik theme alters comment links, so use a different theme. - \Drupal::service('theme_handler')->install(['stark']); + \Drupal::service('theme_installer')->install(['stark']); $this->config('system.theme') ->set('default', 'stark') ->save(); diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php index e295510b8fff..6fc712daf064 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php @@ -490,7 +490,7 @@ class ConfigImportUITest extends BrowserTestBase { */ public function testExtensionValidation() { \Drupal::service('module_installer')->install(['node']); - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); $this->rebuildContainer(); $sync = $this->container->get('config.storage.sync'); diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php index 92aae4c9136f..bcd67fa588b7 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php @@ -164,7 +164,7 @@ class ConfigInstallWebTest extends BrowserTestBase { // Test installing a theme through the API that has existing configuration. try { - \Drupal::service('theme_handler')->install(['config_clash_test_theme']); + \Drupal::service('theme_installer')->install(['config_clash_test_theme']); $this->fail('Expected PreExistingConfigException not thrown.'); } catch (PreExistingConfigException $e) { diff --git a/core/modules/field/tests/src/Kernel/DisplayApiTest.php b/core/modules/field/tests/src/Kernel/DisplayApiTest.php index df1336213354..3dc2b3c98a59 100644 --- a/core/modules/field/tests/src/Kernel/DisplayApiTest.php +++ b/core/modules/field/tests/src/Kernel/DisplayApiTest.php @@ -126,7 +126,7 @@ class DisplayApiTest extends FieldKernelTestBase { public function testFieldItemListView() { $items = $this->entity->get($this->fieldName); - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); // No display settings: check that default display settings are used. diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php index 04352ea93f09..d93d2d238bc6 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php @@ -65,7 +65,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase { parent::setUp(); // Use Classy theme for testing markup output. - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->installEntitySchema('entity_test'); // Grant the 'view test entity' permission. diff --git a/core/modules/file/tests/src/Functional/MultipleFileUploadTest.php b/core/modules/file/tests/src/Functional/MultipleFileUploadTest.php index 587d4479efeb..7ed5ccdcc108 100644 --- a/core/modules/file/tests/src/Functional/MultipleFileUploadTest.php +++ b/core/modules/file/tests/src/Functional/MultipleFileUploadTest.php @@ -31,7 +31,7 @@ class MultipleFileUploadTest extends BrowserTestBase { */ public function testMultipleFileFieldWithAllFileExtensions() { $theme = 'test_theme_settings'; - \Drupal::service('theme_handler')->install([$theme]); + \Drupal::service('theme_installer')->install([$theme]); $this->drupalGet("admin/appearance/settings/$theme"); $edit = []; diff --git a/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php b/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php index 10ef0f643cec..564e8938157c 100644 --- a/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php +++ b/core/modules/help_topics/tests/src/Functional/HelpTopicTest.php @@ -47,7 +47,7 @@ class HelpTopicTest extends BrowserTestBase { // These tests rely on some markup from the 'Seven' theme and we test theme // provided help topics. - \Drupal::service('theme_handler')->install(['seven', 'help_topics_test_theme']); + \Drupal::service('theme_installer')->install(['seven', 'help_topics_test_theme']); \Drupal::service('config.factory')->getEditable('system.theme')->set('admin', 'seven')->save(); // Place various blocks. diff --git a/core/modules/help_topics/tests/src/Functional/HelpTopicTranslationTest.php b/core/modules/help_topics/tests/src/Functional/HelpTopicTranslationTest.php index 323505039a04..d99e0b6426af 100644 --- a/core/modules/help_topics/tests/src/Functional/HelpTopicTranslationTest.php +++ b/core/modules/help_topics/tests/src/Functional/HelpTopicTranslationTest.php @@ -30,7 +30,7 @@ class HelpTopicTranslationTest extends BrowserTestBase { parent::setUp(); // These tests rely on some markup from the 'Seven' theme. - \Drupal::service('theme_handler')->install(['seven']); + \Drupal::service('theme_installer')->install(['seven']); \Drupal::service('config.factory')->getEditable('system.theme')->set('admin', 'seven')->save(); // Place various blocks. diff --git a/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php b/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php index f66ce5247680..9baeff7b29ee 100644 --- a/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php +++ b/core/modules/history/tests/src/Kernel/Views/HistoryTimestampTest.php @@ -42,7 +42,7 @@ class HistoryTimestampTest extends ViewsKernelTestBase { $this->installSchema('history', ['history']); // Use classy theme because its marker is wrapped in a span so it can be // easily targeted with xpath. - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('classy')); } diff --git a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php index 72ee01ac6080..fa1047c377aa 100644 --- a/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php +++ b/core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php @@ -47,7 +47,7 @@ abstract class LayoutBuilderCompatibilityTestBase extends EntityKernelTestBase { // Set up a non-admin user that is allowed to view test entities. \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity'])); - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $field_storage = FieldStorageConfig::create([ diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php index 5f595972f923..42817744a826 100644 --- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php @@ -174,7 +174,7 @@ class MediaSourceOEmbedVideoTest extends MediaSourceTestBase { $this->assertNoRaw('core/modules/media/templates/media-oembed-iframe.html.twig'); // Test themes not inheriting from stable. - \Drupal::service('theme_handler')->install(['stark']); + \Drupal::service('theme_installer')->install(['stark']); $this->config('system.theme')->set('default', 'stark')->save(); $this->drupalGet('media/oembed', ['query' => $query]); $assert_session->pageTextContains('By the power of Greyskull, Vimeo works!'); diff --git a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php index ec3cdf053572..06d9deb050fd 100644 --- a/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php +++ b/core/modules/menu_link_content/tests/src/Functional/MenuLinkContentTranslationUITest.php @@ -88,7 +88,7 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase { $entityId = $this->createEntity([], 'en'); // Set up Seven as the admin theme to test. - $this->container->get('theme_handler')->install(['seven']); + $this->container->get('theme_installer')->install(['seven']); $edit = []; $edit['admin_theme'] = 'seven'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php index 9bff2bce2ed5..42ca89132223 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -233,7 +233,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { $article = $this->drupalCreateNode(['type' => 'article', 'langcode' => $this->langcodes[0]]); // Set up Seven as the admin theme and use it for node editing. - $this->container->get('theme_handler')->install(['seven']); + $this->container->get('theme_installer')->install(['seven']); $edit = []; $edit['admin_theme'] = 'seven'; $edit['use_admin_theme'] = TRUE; diff --git a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php index 8355c19c7a20..a137fb8a8acc 100644 --- a/core/modules/rdf/tests/src/Functional/StandardProfileTest.php +++ b/core/modules/rdf/tests/src/Functional/StandardProfileTest.php @@ -106,7 +106,7 @@ class StandardProfileTest extends BrowserTestBase { parent::setUp(); // Use Classy theme for testing markup output. - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->baseUri = Url::fromRoute('', [], ['absolute' => TRUE])->toString(); diff --git a/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php b/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php index 5c7d38569050..22865183808a 100644 --- a/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php +++ b/core/modules/rdf/tests/src/Kernel/Field/NumberFieldRdfaTest.php @@ -30,7 +30,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase { * Tests the integer formatter with settings. */ public function testIntegerFormatterWithSettings() { - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->fieldType = 'integer'; $formatter = [ @@ -73,7 +73,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase { * Tests the float formatter with settings. */ public function testFloatFormatterWithSettings() { - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->fieldType = 'float'; $formatter = [ @@ -123,7 +123,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase { * Tests the float formatter with a scale. Scale is exercised. */ public function testFloatFormatterWithScaleExercised() { - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->fieldType = 'float'; $formatter = [ @@ -161,7 +161,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase { * Tests the decimal formatter with settings. */ public function testDecimalFormatterWithSettings() { - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->fieldType = 'decimal'; $formatter = [ diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php index 10a7b8159840..f14109b539e5 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php @@ -140,7 +140,7 @@ class ShortcutLinksTest extends ShortcutTestBase { * Tests that the "add to shortcut" and "remove from shortcut" links work. */ public function testShortcutQuickLink() { - \Drupal::service('theme_handler')->install(['seven']); + \Drupal::service('theme_installer')->install(['seven']); $this->config('system.theme')->set('admin', 'seven')->save(); $this->config('node.settings')->set('use_admin_theme', '1')->save(); $this->container->get('router.builder')->rebuild(); @@ -305,7 +305,7 @@ class ShortcutLinksTest extends ShortcutTestBase { */ public function testNoShortcutLink() { // Change to a theme that displays shortcuts. - \Drupal::service('theme_handler')->install(['seven']); + \Drupal::service('theme_installer')->install(['seven']); $this->config('system.theme') ->set('default', 'seven') ->save(); @@ -336,7 +336,7 @@ class ShortcutLinksTest extends ShortcutTestBase { */ public function testAccessShortcutsPermission() { // Change to a theme that displays shortcuts. - \Drupal::service('theme_handler')->install(['seven']); + \Drupal::service('theme_installer')->install(['seven']); $this->config('system.theme') ->set('default', 'seven') ->save(); diff --git a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php index 90a62093b61d..42f1a225e5a9 100644 --- a/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php +++ b/core/modules/statistics/tests/src/Functional/StatisticsAttachedTest.php @@ -29,7 +29,7 @@ class StatisticsAttachedTest extends BrowserTestBase { // Install "statistics_test_attached" and set it as the default theme. $theme = 'statistics_test_attached'; - \Drupal::service('theme_handler')->install([$theme]); + \Drupal::service('theme_installer')->install([$theme]); $this->config('system.theme') ->set('default', $theme) ->save(); diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php index 31be59ed1a43..29a015f5d0c6 100644 --- a/core/modules/system/src/Controller/ThemeController.php +++ b/core/modules/system/src/Controller/ThemeController.php @@ -7,6 +7,7 @@ use Drupal\Core\Config\PreExistingConfigException; use Drupal\Core\Config\UnmetDependenciesException; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Extension\ThemeHandlerInterface; +use Drupal\Core\Extension\ThemeInstallerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -23,6 +24,13 @@ class ThemeController extends ControllerBase { */ protected $themeHandler; + /** + * The theme installer service. + * + * @var \Drupal\Core\Extension\ThemeInstallerInterface + */ + protected $themeInstaller; + /** * Constructs a new ThemeController. * @@ -30,10 +38,13 @@ class ThemeController extends ControllerBase { * The theme handler. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. + * @param \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer + * The theme installer. */ - public function __construct(ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory) { + public function __construct(ThemeHandlerInterface $theme_handler, ConfigFactoryInterface $config_factory, ThemeInstallerInterface $theme_installer) { $this->themeHandler = $theme_handler; $this->configFactory = $config_factory; + $this->themeInstaller = $theme_installer; } /** @@ -42,7 +53,8 @@ class ThemeController extends ControllerBase { public static function create(ContainerInterface $container) { return new static( $container->get('theme_handler'), - $container->get('config.factory') + $container->get('config.factory'), + $container->get('theme_installer') ); } @@ -74,7 +86,7 @@ class ThemeController extends ControllerBase { $this->messenger()->addError($this->t('%theme is the default theme and cannot be uninstalled.', ['%theme' => $themes[$theme]->info['name']])); } else { - $this->themeHandler->uninstall([$theme]); + $this->themeInstaller->uninstall([$theme]); $this->messenger()->addStatus($this->t('The %theme theme has been uninstalled.', ['%theme' => $themes[$theme]->info['name']])); } } @@ -106,7 +118,7 @@ class ThemeController extends ControllerBase { if (isset($theme)) { try { - if ($this->themeHandler->install([$theme])) { + if ($this->themeInstaller->install([$theme])) { $themes = $this->themeHandler->listInfo(); $this->messenger()->addStatus($this->t('The %theme theme has been installed.', ['%theme' => $themes[$theme]->info['name']])); } @@ -159,7 +171,7 @@ class ThemeController extends ControllerBase { // Check if the specified theme is one recognized by the system. // Or try to install the theme. - if (isset($themes[$theme]) || $this->themeHandler->install([$theme])) { + if (isset($themes[$theme]) || $this->themeInstaller->install([$theme])) { $themes = $this->themeHandler->listInfo(); // Set the default theme. diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 1dec9d14c900..a4d467d2539f 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1854,12 +1854,13 @@ function system_update_8014() { return; } $theme_handler->refreshInfo(); + $theme_installer = \Drupal::service('theme_installer'); foreach ($theme_handler->listInfo() as $theme) { // We first check that a base theme is set because if it's set to false then // it's unset in // \Drupal\Core\Extension\ThemeExtensionList::createExtensionInfo(). if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') { - $theme_handler->install(['stable']); + $theme_installer->install(['stable']); return; } } diff --git a/core/modules/system/tests/src/Functional/Batch/PageTest.php b/core/modules/system/tests/src/Functional/Batch/PageTest.php index b1e46a2ea5fb..b979eee4129f 100644 --- a/core/modules/system/tests/src/Functional/Batch/PageTest.php +++ b/core/modules/system/tests/src/Functional/Batch/PageTest.php @@ -24,7 +24,7 @@ class PageTest extends BrowserTestBase { public function testBatchProgressPageTheme() { // Make sure that the page which starts the batch (an administrative page) // is using a different theme than would normally be used by the batch API. - $this->container->get('theme_handler')->install(['seven', 'bartik']); + $this->container->get('theme_installer')->install(['seven', 'bartik']); $this->config('system.theme') ->set('default', 'bartik') ->set('admin', 'seven') diff --git a/core/modules/system/tests/src/Functional/Common/AlterTest.php b/core/modules/system/tests/src/Functional/Common/AlterTest.php index e529e9d1c2d7..00b6e5be452d 100644 --- a/core/modules/system/tests/src/Functional/Common/AlterTest.php +++ b/core/modules/system/tests/src/Functional/Common/AlterTest.php @@ -24,7 +24,7 @@ class AlterTest extends BrowserTestBase { public function testDrupalAlter() { // This test depends on Bartik, so make sure that it is always the current // active theme. - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('bartik')); $array = ['foo' => 'bar']; diff --git a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php index 4296df55bde1..882d92365af5 100644 --- a/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php +++ b/core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php @@ -247,8 +247,9 @@ class MenuRouterTest extends BrowserTestBase { $this->defaultTheme = 'bartik'; $this->adminTheme = 'seven'; - $theme_handler = $this->container->get('theme_handler'); - $theme_handler->install([$this->defaultTheme, $this->adminTheme]); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = $this->container->get('theme_installer'); + $theme_installer->install([$this->defaultTheme, $this->adminTheme]); $this->config('system.theme') ->set('default', $this->defaultTheme) ->set('admin', $this->adminTheme) @@ -305,14 +306,15 @@ class MenuRouterTest extends BrowserTestBase { $this->assertRaw('bartik/css/base/elements.css', "The default theme's CSS appears on the page."); // Now install the theme and request it again. - $theme_handler = $this->container->get('theme_handler'); - $theme_handler->install(['test_theme']); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = $this->container->get('theme_installer'); + $theme_installer->install(['test_theme']); $this->drupalGet('menu-test/theme-callback/use-test-theme'); $this->assertText('Active theme: test_theme. Actual theme: test_theme.', 'The theme negotiation system uses an optional theme once it has been installed.'); $this->assertRaw('test_theme/kitten.css', "The optional theme's CSS appears on the page."); - $theme_handler->uninstall(['test_theme']); + $theme_installer->uninstall(['test_theme']); } /** diff --git a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php index d519c7351e99..8d2e42d870a5 100644 --- a/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php +++ b/core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php @@ -136,7 +136,7 @@ class SiteMaintenanceTest extends BrowserTestBase { $this->assertText($user_message); // Regression test to check if title displays in Bartik on maintenance page. - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); $this->config('system.theme')->set('default', 'bartik')->save(); // Logout and verify that offline message is displayed in Bartik. diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php index 3e3f9d31abdf..a107459ff6d6 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -189,7 +189,7 @@ class ThemeTest extends BrowserTestBase { ); $this->assertEqual($elements[0]->getAttribute('src'), file_url_transform_relative(file_create_url($uploaded_filename))); - $this->container->get('theme_handler')->install(['bartik']); + $this->container->get('theme_installer')->install(['bartik']); // Ensure only valid themes are listed in the local tasks. $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']); @@ -226,7 +226,7 @@ class ThemeTest extends BrowserTestBase { */ public function testThemeSettingsLogo() { // Visit Bartik's theme settings page to replace the logo. - $this->container->get('theme_handler')->install(['bartik']); + $this->container->get('theme_installer')->install(['bartik']); $this->drupalGet('admin/appearance/settings/bartik'); $edit = [ 'default_logo' => FALSE, @@ -248,7 +248,7 @@ class ThemeTest extends BrowserTestBase { * Tests the 'rendered' cache tag is cleared when saving theme settings. */ public function testThemeSettingsRenderCacheClear() { - $this->container->get('theme_handler')->install(['bartik']); + $this->container->get('theme_installer')->install(['bartik']); // Ensure the frontpage is cached for anonymous users. The render cache will // cleared by installing a theme. $this->drupalLogout(); @@ -270,7 +270,7 @@ class ThemeTest extends BrowserTestBase { * Test the administration theme functionality. */ public function testAdministrationTheme() { - $this->container->get('theme_handler')->install(['seven']); + $this->container->get('theme_installer')->install(['seven']); // Install an administration theme and show it on the node admin pages. $edit = [ @@ -329,14 +329,14 @@ class ThemeTest extends BrowserTestBase { * Test switching the default theme. */ public function testSwitchDefaultTheme() { - /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ - $theme_handler = \Drupal::service('theme_handler'); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = \Drupal::service('theme_installer'); // First, install Stark and set it as the default theme programmatically. - $theme_handler->install(['stark']); + $theme_installer->install(['stark']); $this->config('system.theme')->set('default', 'stark')->save(); // Install Bartik and set it as the default theme. - $theme_handler->install(['bartik']); + $theme_installer->install(['bartik']); $this->drupalGet('admin/appearance'); $this->clickLink(t('Set as default')); $this->assertEqual($this->config('system.theme')->get('default'), 'bartik'); @@ -378,9 +378,9 @@ class ThemeTest extends BrowserTestBase { */ public function testUninstallingThemes() { // Install Bartik and set it as the default theme. - \Drupal::service('theme_handler')->install(['bartik']); + \Drupal::service('theme_installer')->install(['bartik']); // Set up seven as the admin theme. - \Drupal::service('theme_handler')->install(['seven']); + \Drupal::service('theme_installer')->install(['seven']); $edit = [ 'admin_theme' => 'seven', 'use_admin_theme' => TRUE, @@ -398,7 +398,7 @@ class ThemeTest extends BrowserTestBase { $this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.'); // Install Stark and set it as the default theme. - \Drupal::service('theme_handler')->install(['stark']); + \Drupal::service('theme_installer')->install(['stark']); $edit = [ 'admin_theme' => 'stark', @@ -462,7 +462,7 @@ class ThemeTest extends BrowserTestBase { */ public function testThemeSettingsNoLogoNoFavicon() { // Install theme with no logo and no favicon feature. - $this->container->get('theme_handler')->install(['test_theme_settings_features']); + $this->container->get('theme_installer')->install(['test_theme_settings_features']); // Visit this theme's settings page. $this->drupalGet('admin/appearance/settings/test_theme_settings_features'); $edit = []; diff --git a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php index 6dca1b38d3cd..368e1276c7cf 100644 --- a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php @@ -20,7 +20,7 @@ class EngineNyanCatTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme_nyan_cat_engine']); + \Drupal::service('theme_installer')->install(['test_theme_nyan_cat_engine']); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php index 1e1cb5363b7b..c832b2934c77 100644 --- a/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php @@ -25,7 +25,7 @@ class EngineTwigTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php b/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php index 6e4bd0a0b38a..a921e873434a 100644 --- a/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php @@ -82,7 +82,7 @@ class EntityFilteringThemeTest extends BrowserTestBase { // Install all available non-testing themes. $listing = new ExtensionDiscovery(\Drupal::root()); $this->themes = $listing->scan('theme', FALSE); - \Drupal::service('theme_handler')->install(array_keys($this->themes)); + \Drupal::service('theme_installer')->install(array_keys($this->themes)); // Create a test user. $this->user = $this->drupalCreateUser(['access content', 'access user profiles']); diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php index e372bb262a6c..8d972c045a1e 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php @@ -19,11 +19,11 @@ class ThemeInfoTest extends BrowserTestBase { public static $modules = ['theme_test']; /** - * The theme handler used in this test for enabling themes. + * The theme installer used in this test for enabling themes. * - * @var \Drupal\Core\Extension\ThemeHandler + * @var \Drupal\Core\Extension\ThemeInstallerInterface */ - protected $themeHandler; + protected $themeInstaller; /** * The theme manager used in this test. @@ -45,7 +45,7 @@ class ThemeInfoTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - $this->themeHandler = $this->container->get('theme_handler'); + $this->themeInstaller = $this->container->get('theme_installer'); $this->themeManager = $this->container->get('theme.manager'); $this->state = $this->container->get('state'); } @@ -54,7 +54,7 @@ class ThemeInfoTest extends BrowserTestBase { * Tests stylesheets-remove. */ public function testStylesheets() { - $this->themeHandler->install(['test_basetheme', 'test_subtheme']); + $this->themeInstaller->install(['test_basetheme', 'test_subtheme']); $this->config('system.theme') ->set('default', 'test_subtheme') ->save(); @@ -83,7 +83,7 @@ class ThemeInfoTest extends BrowserTestBase { * Tests that changes to the info file are picked up. */ public function testChanges() { - $this->themeHandler->install(['test_theme']); + $this->themeInstaller->install(['test_theme']); $this->config('system.theme')->set('default', 'test_theme')->save(); $this->themeManager->resetActiveTheme(); diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php index 36e8eb2d6094..cac5e31c1fb4 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeSuggestionsAlterTest.php @@ -21,7 +21,7 @@ class ThemeSuggestionsAlterTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeTest.php index 545fc587aa54..019077de55c1 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeTest.php @@ -25,7 +25,7 @@ class ThemeTest extends BrowserTestBase { */ protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php b/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php index 85f44d437fd3..e67a6341be58 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigDebugMarkupTest.php @@ -26,7 +26,7 @@ class TwigDebugMarkupTest extends BrowserTestBase { /** @var \Drupal\Core\Render\RendererInterface $renderer */ $renderer = $this->container->get('renderer'); $extension = twig_extension(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->config('system.theme')->set('default', 'test_theme')->save(); $this->drupalCreateContentType(['type' => 'page']); // Enable debug, rebuild the service container, and clear all caches. diff --git a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php index 588b947e6e02..3966d6843a45 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php @@ -21,7 +21,7 @@ class TwigExtensionTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); } /** diff --git a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php index d6edd006418e..4cc7c69f6530 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php @@ -26,7 +26,7 @@ class TwigRegistryLoaderTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme']); + \Drupal::service('theme_installer')->install(['test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme']); $this->twig = \Drupal::service('twig'); } diff --git a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php index fd759502e3a6..d0c333606c3a 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php @@ -76,8 +76,8 @@ class TwigSettingsTest extends BrowserTestBase { */ public function testTwigCacheOverride() { $extension = twig_extension(); - $theme_handler = $this->container->get('theme_handler'); - $theme_handler->install(['test_theme']); + $theme_installer = $this->container->get('theme_installer'); + $theme_installer->install(['test_theme']); $this->config('system.theme')->set('default', 'test_theme')->save(); // The registry still works on theme globals, so set them here. diff --git a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php index 0bd3919dd1af..c664c5dd7340 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php @@ -48,7 +48,7 @@ class TwigTransTest extends BrowserTestBase { parent::setUp(); // Setup test_theme. - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->config('system.theme')->set('default', 'test_theme')->save(); // Create and log in as admin. diff --git a/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php b/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php index 4d8fd5fb9117..c23f9847c05b 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php @@ -98,7 +98,7 @@ class FrameworkTest extends WebDriverTestBase { public function testLazyLoadOverriddenCSS() { // The test theme overrides js.module.css without an implementation, // thereby removing it. - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->config('system.theme') ->set('default', 'test_theme') ->save(); diff --git a/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php b/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php index 4f3e9f1d49cb..821a987ed8b9 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php @@ -37,7 +37,7 @@ class ThemeFormSettingsTest extends WebDriverTestBase { */ public function testFormSettingsSubmissionHandler($theme) { - \Drupal::service('theme_handler')->install([$theme]); + \Drupal::service('theme_installer')->install([$theme]); $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); diff --git a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateThemeSettingsTest.php b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateThemeSettingsTest.php index 08f70cff7398..ba4747c8c040 100644 --- a/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateThemeSettingsTest.php +++ b/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateThemeSettingsTest.php @@ -17,10 +17,8 @@ class MigrateThemeSettingsTest extends MigrateDrupal7TestBase { protected function setUp() { parent::setUp(); - // Install bartik theme. - \Drupal::service('theme_handler')->install(['bartik']); - // Install seven theme. - \Drupal::service('theme_handler')->install(['seven']); + // Install bartik and seven themes. + \Drupal::service('theme_installer')->install(['bartik', 'seven']); $this->executeMigration('d7_theme_settings'); } diff --git a/core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php b/core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php index 2826a3225e61..0e33530e7564 100644 --- a/core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php +++ b/core/modules/system/tests/src/Kernel/Theme/FunctionsTest.php @@ -31,7 +31,7 @@ class FunctionsTest extends KernelTestBase { parent::setUp(); // Enable the Classy theme. - $this->container->get('theme_handler')->install(['classy']); + $this->container->get('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); } diff --git a/core/modules/system/tests/src/Kernel/Theme/ThemeTest.php b/core/modules/system/tests/src/Kernel/Theme/ThemeTest.php index b8ecab484757..49b723b285f1 100644 --- a/core/modules/system/tests/src/Kernel/Theme/ThemeTest.php +++ b/core/modules/system/tests/src/Kernel/Theme/ThemeTest.php @@ -23,7 +23,7 @@ class ThemeTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); } /** @@ -104,8 +104,8 @@ class ThemeTest extends KernelTestBase { * Test the listInfo() function. */ public function testListThemes() { + $this->container->get('theme_installer')->install(['test_subtheme']); $theme_handler = $this->container->get('theme_handler'); - $theme_handler->install(['test_subtheme']); $themes = $theme_handler->listInfo(); // Check if ThemeHandlerInterface::listInfo() retrieves enabled themes. diff --git a/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php b/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php index b08c9cb1c04b..43ba48fb3a83 100644 --- a/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php +++ b/core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php @@ -26,7 +26,7 @@ class TwigNamespaceTest extends KernelTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme', 'bartik']); + \Drupal::service('theme_installer')->install(['test_theme', 'bartik']); $this->twig = \Drupal::service('twig'); } diff --git a/core/modules/taxonomy/tests/src/Functional/ThemeTest.php b/core/modules/taxonomy/tests/src/Functional/ThemeTest.php index 43ed72c9eece..bf6c6b57daf3 100644 --- a/core/modules/taxonomy/tests/src/Functional/ThemeTest.php +++ b/core/modules/taxonomy/tests/src/Functional/ThemeTest.php @@ -14,7 +14,7 @@ class ThemeTest extends TaxonomyTestBase { // Make sure we are using distinct default and administrative themes for // the duration of these tests. - \Drupal::service('theme_handler')->install(['bartik', 'seven']); + \Drupal::service('theme_installer')->install(['bartik', 'seven']); $this->config('system.theme') ->set('default', 'bartik') ->set('admin', 'seven') diff --git a/core/modules/tour/tests/src/Functional/TourTestBasic.php b/core/modules/tour/tests/src/Functional/TourTestBasic.php index ca188d7075cd..2f4d9674dc8b 100644 --- a/core/modules/tour/tests/src/Functional/TourTestBasic.php +++ b/core/modules/tour/tests/src/Functional/TourTestBasic.php @@ -44,7 +44,7 @@ abstract class TourTestBasic extends TourTestBase { // Make sure we are using distinct default and administrative themes for // the duration of these tests. - $this->container->get('theme_handler')->install(['bartik', 'seven']); + $this->container->get('theme_installer')->install(['bartik', 'seven']); $this->config('system.theme') ->set('default', 'bartik') ->set('admin', 'seven') diff --git a/core/modules/update/tests/src/Functional/UpdateContribTest.php b/core/modules/update/tests/src/Functional/UpdateContribTest.php index aa0d44abd653..06ebbde0d111 100644 --- a/core/modules/update/tests/src/Functional/UpdateContribTest.php +++ b/core/modules/update/tests/src/Functional/UpdateContribTest.php @@ -188,7 +188,7 @@ class UpdateContribTest extends UpdateTestBase { // @todo https://www.drupal.org/node/2338175 base themes have to be // installed. // Only install the subtheme, not the base theme. - \Drupal::service('theme_handler')->install(['update_test_subtheme']); + \Drupal::service('theme_installer')->install(['update_test_subtheme']); // Define the initial state for core and the subtheme. $system_info = [ @@ -295,7 +295,7 @@ class UpdateContribTest extends UpdateTestBase { module_load_include('compare.inc', 'update'); // Install the subtheme. - \Drupal::service('theme_handler')->install(['update_test_subtheme']); + \Drupal::service('theme_installer')->install(['update_test_subtheme']); // Add a project and initial state for base theme and subtheme. $system_info = [ diff --git a/core/modules/user/tests/src/Kernel/UserFieldsTest.php b/core/modules/user/tests/src/Kernel/UserFieldsTest.php index 321792ecc6e3..70874265cd2b 100644 --- a/core/modules/user/tests/src/Kernel/UserFieldsTest.php +++ b/core/modules/user/tests/src/Kernel/UserFieldsTest.php @@ -27,7 +27,7 @@ class UserFieldsTest extends KernelTestBase { $this->installEntitySchema('user'); // Set up a test theme that prints the user's mail field. - \Drupal::service('theme_handler')->install(['user_test_theme']); + \Drupal::service('theme_installer')->install(['user_test_theme']); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('user_test_theme')); // Clear the theme registry. $this->container->set('theme.registry', NULL); diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php index 3f807f67d680..cecc8fabd2a8 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormCheckboxesTest.php @@ -79,7 +79,7 @@ class ExposedFormCheckboxesTest extends ViewTestBase { */ public function testExposedFormRenderCheckboxes() { // Use a test theme to convert multi-select elements into checkboxes. - \Drupal::service('theme_handler')->install(['views_test_checkboxes_theme']); + \Drupal::service('theme_installer')->install(['views_test_checkboxes_theme']); $this->config('system.theme') ->set('default', 'views_test_checkboxes_theme') ->save(); @@ -142,7 +142,7 @@ class ExposedFormCheckboxesTest extends ViewTestBase { ]); // Use a test theme to convert multi-select elements into checkboxes. - \Drupal::service('theme_handler')->install(['views_test_checkboxes_theme']); + \Drupal::service('theme_installer')->install(['views_test_checkboxes_theme']); $this->config('system.theme') ->set('default', 'views_test_checkboxes_theme') ->save(); diff --git a/core/modules/views/tests/src/Functional/ViewsEscapingTest.php b/core/modules/views/tests/src/Functional/ViewsEscapingTest.php index 80a839872226..d66d90863c52 100644 --- a/core/modules/views/tests/src/Functional/ViewsEscapingTest.php +++ b/core/modules/views/tests/src/Functional/ViewsEscapingTest.php @@ -47,7 +47,7 @@ class ViewsEscapingTest extends ViewTestBase { $this->assertNoEscaped('<'); // Install theme to test with template system. - \Drupal::service('theme_handler')->install(['views_test_theme']); + \Drupal::service('theme_installer')->install(['views_test_theme']); // Make base theme default then test for hook invocations. $this->config('system.theme') diff --git a/core/modules/views/tests/src/Functional/ViewsNoResultsBehaviorTest.php b/core/modules/views/tests/src/Functional/ViewsNoResultsBehaviorTest.php index 1a2146d3ab20..bb8a77eca29a 100644 --- a/core/modules/views/tests/src/Functional/ViewsNoResultsBehaviorTest.php +++ b/core/modules/views/tests/src/Functional/ViewsNoResultsBehaviorTest.php @@ -26,9 +26,9 @@ class ViewsNoResultsBehaviorTest extends ViewTestBase { $this->drupalLogin($user); // Set the Stark theme and use the default templates from views module. - /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ - $theme_handler = \Drupal::service('theme_handler'); - $theme_handler->install(['stark']); + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = \Drupal::service('theme_installer'); + $theme_installer->install(['stark']); $this->config('system.theme')->set('default', 'stark')->save(); } diff --git a/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php b/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php index 9bdb405b86fd..5807dad53518 100644 --- a/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php +++ b/core/modules/views/tests/src/Functional/ViewsThemeIntegrationTest.php @@ -45,7 +45,7 @@ class ViewsThemeIntegrationTest extends ViewTestBase { */ public function testThemedViewPage() { - \Drupal::service('theme_handler')->install(['test_basetheme', 'test_subtheme']); + \Drupal::service('theme_installer')->install(['test_basetheme', 'test_subtheme']); // Make base theme default then test for hook invocations. $this->config('system.theme') diff --git a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php index 7418b81ca0f3..07dff07dfd14 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/DisplayPageTest.php @@ -239,7 +239,7 @@ class DisplayPageTest extends ViewsKernelTestBase { $themes = ['bartik', 'classy', 'seven', 'stable', 'stark']; foreach ($themes as $theme) { - \Drupal::service('theme_handler')->install([$theme]); + \Drupal::service('theme_installer')->install([$theme]); \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme($theme)); foreach ($styles as $type => $xpath) { $view = Views::getView('test_page_display'); diff --git a/core/modules/views/tests/src/Kernel/ViewsPreprocessTest.php b/core/modules/views/tests/src/Kernel/ViewsPreprocessTest.php index ab8bc7704aff..f66be0ad2e45 100644 --- a/core/modules/views/tests/src/Kernel/ViewsPreprocessTest.php +++ b/core/modules/views/tests/src/Kernel/ViewsPreprocessTest.php @@ -35,7 +35,7 @@ class ViewsPreprocessTest extends ViewsKernelTestBase { * Tests css classes on displays are cleaned correctly. */ public function testCssClassCleaning() { - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->config('system.theme')->set('default', 'test_theme')->save(); $entity = EntityTest::create(); diff --git a/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php index 33ad6803d578..a8219a34b7a1 100644 --- a/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php +++ b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php @@ -107,7 +107,7 @@ class CustomBooleanTest extends UITestBase { */ public function testCustomOptionTemplate() { // Install theme to test with template system. - \Drupal::service('theme_handler')->install(['views_test_theme']); + \Drupal::service('theme_installer')->install(['views_test_theme']); // Set the default theme for Views preview. $this->config('system.theme') diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php index 48a031606172..4772366c1150 100644 --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php @@ -34,7 +34,7 @@ class GetFilenameTest extends KernelTestBase { $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml'); // Retrieving the location of a theme. - \Drupal::service('theme_handler')->install(['stark']); + \Drupal::service('theme_installer')->install(['stark']); $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml'); // Retrieving the location of a theme engine. diff --git a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php index f06806cad6fd..fb147d782f73 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php @@ -38,7 +38,7 @@ class DefaultConfigTest extends KernelTestBase { protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install($this->themes); + \Drupal::service('theme_installer')->install($this->themes); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php index f75af9929d73..a4fb3fef1a52 100644 --- a/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php @@ -21,7 +21,7 @@ class CurrentThemeConditionTest extends KernelTestBase { * Tests the current theme condition. */ public function testCurrentTheme() { - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $manager = \Drupal::service('plugin.manager.condition'); /** @var $condition \Drupal\Core\Condition\ConditionInterface */ diff --git a/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php b/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php index 76fcbb4fdcfd..f32b490d5bf3 100644 --- a/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php +++ b/core/tests/Drupal/KernelTests/Core/Render/Element/TableTest.php @@ -82,7 +82,7 @@ class TableTest extends KernelTestBase { ]; // Enable the Classy theme. - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); $this->render($table); diff --git a/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php index cd33fcb6dce9..f5b58c6445c8 100644 --- a/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Render/ElementInfoIntegrationTest.php @@ -17,7 +17,7 @@ class ElementInfoIntegrationTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->container->get('theme_handler')->install(['test_theme', 'classy']); + $this->container->get('theme_installer')->install(['test_theme', 'classy']); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php index 5552591ed1a4..6e594f358ef5 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php @@ -21,7 +21,7 @@ class MessageTest extends KernelTestBase { */ public function testMessages() { // Enable the Classy theme. - \Drupal::service('theme_handler')->install(['classy']); + \Drupal::service('theme_installer')->install(['classy']); $this->config('system.theme')->set('default', 'classy')->save(); \Drupal::messenger()->addError('An error occurred'); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php index 320e92f46a14..ffbe543db7fd 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php @@ -67,7 +67,7 @@ class RegistryTest extends KernelTestBase { */ public function testMultipleSubThemes() { $theme_handler = \Drupal::service('theme_handler'); - $theme_handler->install(['test_basetheme', 'test_subtheme', 'test_subsubtheme']); + \Drupal::service('theme_installer')->install(['test_basetheme', 'test_subtheme', 'test_subsubtheme']); $registry_subsub_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subsubtheme'); $registry_subsub_theme->setThemeManager(\Drupal::theme()); @@ -109,7 +109,7 @@ class RegistryTest extends KernelTestBase { */ public function testSuggestionPreprocessFunctions() { $theme_handler = \Drupal::service('theme_handler'); - $theme_handler->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $registry_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme'); $registry_theme->setThemeManager(\Drupal::theme()); @@ -151,7 +151,7 @@ class RegistryTest extends KernelTestBase { /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ $theme_handler = \Drupal::service('theme_handler'); - $theme_handler->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->config('system.theme')->set('default', 'test_theme')->save(); $registry = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme'); @@ -197,7 +197,7 @@ class RegistryTest extends KernelTestBase { */ public function testThemeTemplatesRegisteredByModules() { $theme_handler = \Drupal::service('theme_handler'); - $theme_handler->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $registry_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme'); $registry_theme->setThemeManager(\Drupal::theme()); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php index 8566b0e8dc9e..8e106947b6bf 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableThemeTest.php @@ -19,11 +19,11 @@ class StableThemeTest extends KernelTestBase { public static $modules = ['system']; /** - * The theme handler. + * The theme installer. * - * @var \Drupal\Core\Extension\ThemeHandlerInterface + * @var \Drupal\Core\Extension\ThemeInstallerInterface */ - protected $themeHandler; + protected $themeInstaller; /** * The theme manager. @@ -38,7 +38,7 @@ class StableThemeTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->themeHandler = $this->container->get('theme_handler'); + $this->themeInstaller = $this->container->get('theme_installer'); $this->themeManager = $this->container->get('theme.manager'); } @@ -46,7 +46,7 @@ class StableThemeTest extends KernelTestBase { * Ensures Stable is used by default when no base theme has been defined. */ public function testStableIsDefault() { - $this->themeHandler->install(['test_stable']); + $this->themeInstaller->install(['test_stable']); $this->config('system.theme')->set('default', 'test_stable')->save(); $theme = $this->themeManager->getActiveTheme(); $base_themes = $theme->getBaseThemeExtensions(); @@ -58,7 +58,7 @@ class StableThemeTest extends KernelTestBase { * Tests opting out of Stable by setting the base theme to false. */ public function testWildWest() { - $this->themeHandler->install(['test_wild_west']); + $this->themeInstaller->install(['test_wild_west']); $this->config('system.theme')->set('default', 'test_wild_west')->save(); $theme = $this->themeManager->getActiveTheme(); /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */ diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeHandlerLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeHandlerLegacyTest.php new file mode 100644 index 000000000000..2cc277ae1da0 --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeHandlerLegacyTest.php @@ -0,0 +1,46 @@ +themeHandler = \Drupal::service('theme_handler'); + } + + /** + * @covers ::install + * @covers ::uninstall + * @expectedDeprecation \Drupal\Core\Extension\ThemeHandlerInterface::install() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\ThemeInstallerInterface::install() instead. See https://www.drupal.org/node/3017233 + * @expectedDeprecation \Drupal\Core\Extension\ThemeHandlerInterface::uninstall() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Extension\ThemeInstallerInterface::uninstall() instead. See https://www.drupal.org/node/3017233 + */ + public function testInstallUninstall() { + $theme = 'seven'; + + $this->assertFalse($this->themeHandler->themeExists($theme)); + $this->assertEquals(TRUE, $this->themeHandler->install([$theme])); + $this->assertTrue($this->themeHandler->themeExists($theme)); + $this->themeHandler->uninstall([$theme]); + $this->assertFalse($this->themeHandler->themeExists($theme)); + } + +} diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php index 180b708a3766..f6e8ee7136fd 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php @@ -109,7 +109,7 @@ class ThemeInstallerTest extends KernelTestBase { $this->assertFalse(array_keys($themes)); try { - $message = 'ThemeHandler::install() throws UnknownExtensionException upon installing a non-existing theme.'; + $message = 'ThemeInstaller::install() throws UnknownExtensionException upon installing a non-existing theme.'; $this->themeInstaller()->install([$name]); $this->fail($message); } @@ -128,7 +128,7 @@ class ThemeInstallerTest extends KernelTestBase { $name = 'test_theme_having_veery_long_name_which_is_too_long'; try { - $message = 'ThemeHandler::install() throws ExtensionNameLengthException upon installing a theme with a too long name.'; + $message = 'ThemeInstaller::install() throws ExtensionNameLengthException upon installing a theme with a too long name.'; $this->themeInstaller()->install([$name]); $this->fail($message); } @@ -151,8 +151,8 @@ class ThemeInstallerTest extends KernelTestBase { $this->assertTrue(isset($themes[$other_name])); try { - $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling default theme.'; - $this->themeHandler()->uninstall([$name]); + $message = 'ThemeInstaller::uninstall() throws InvalidArgumentException upon disabling default theme.'; + $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -178,8 +178,8 @@ class ThemeInstallerTest extends KernelTestBase { $this->assertTrue(isset($themes[$other_name])); try { - $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling admin theme.'; - $this->themeHandler()->uninstall([$name]); + $message = 'ThemeInstaller::uninstall() throws InvalidArgumentException upon disabling admin theme.'; + $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -216,7 +216,7 @@ class ThemeInstallerTest extends KernelTestBase { $this->themeInstaller()->install([$sub_name]); try { - $message = 'ThemeHandler::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.'; + $message = 'ThemeInstaller::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.'; $this->themeInstaller()->uninstall([$name]); $this->fail($message); } @@ -246,7 +246,7 @@ class ThemeInstallerTest extends KernelTestBase { $this->assertFalse(array_keys($themes)); try { - $message = 'ThemeHandler::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.'; + $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a non-existing theme.'; $this->themeInstaller()->uninstall([$name]); $this->fail($message); } @@ -288,7 +288,7 @@ class ThemeInstallerTest extends KernelTestBase { $name = 'test_basetheme'; try { - $message = 'ThemeHandler::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.'; + $message = 'ThemeInstaller::uninstall() throws UnknownExtensionException upon uninstalling a theme that is not installed.'; $this->themeInstaller()->uninstall([$name]); $this->fail($message); } diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php index cf0e7d2c2122..9e70d1955935 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php @@ -45,7 +45,7 @@ class ThemeSettingsTest extends KernelTestBase { $name = 'test_basetheme'; $path = $this->availableThemes[$name]->getPath(); $this->assertTrue(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml")); - $this->container->get('theme_handler')->install([$name]); + $this->container->get('theme_installer')->install([$name]); $this->assertIdentical(theme_get_setting('base', $name), 'only'); } @@ -56,7 +56,7 @@ class ThemeSettingsTest extends KernelTestBase { $name = 'stark'; $path = $this->availableThemes[$name]->getPath(); $this->assertFalse(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml")); - $this->container->get('theme_handler')->install([$name]); + $this->container->get('theme_installer')->install([$name]); $this->assertNotNull(theme_get_setting('features.favicon', $name)); } @@ -64,9 +64,11 @@ class ThemeSettingsTest extends KernelTestBase { * Tests that the default logo config can be overridden. */ public function testLogoConfig() { + /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */ + $theme_installer = $this->container->get('theme_installer'); + $theme_installer->install(['stark']); /** @var \Drupal\Core\Extension\ThemeHandler $theme_handler */ $theme_handler = $this->container->get('theme_handler'); - $theme_handler->install(['stark']); $theme = $theme_handler->getTheme('stark'); // Tests default behaviour. @@ -98,7 +100,7 @@ class ThemeSettingsTest extends KernelTestBase { $expected = '/' . $theme->getPath() . '/logo_relative_path.gif'; $this->assertEquals($expected, theme_get_setting('logo.url', 'stark')); - $theme_handler->install(['test_theme']); + $theme_installer->install(['test_theme']); $theme_handler->setDefault('test_theme'); $theme = $theme_handler->getTheme('test_theme'); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php index 6721e5cb0b05..0a3b3ed66eb7 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php @@ -42,7 +42,7 @@ class TwigWhiteListTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(['test_theme']); + \Drupal::service('theme_installer')->install(['test_theme']); $this->installSchema('system', ['sequences']); $this->installEntitySchema('node'); $this->installEntitySchema('user');