Commit c12498bd authored by catch's avatar catch
Browse files

Issue #2776031 by fgm, andypost, voleger, yogeshmpawar, Berdir, joachim:...

Issue #2776031 by fgm, andypost, voleger, yogeshmpawar, Berdir, joachim: Properly deprecate ThemeHandlerInterface install() and uninstall() also replace usage
parent 1fd92fcd
......@@ -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()
......
......@@ -829,7 +829,7 @@ protected function processExtension($type, $op, $name) {
$this->configManager->getConfigFactory()->reset('system.theme');
$this->processedSystemTheme = TRUE;
}
$this->themeHandler->$op([$name]);
\Drupal::service('theme_installer')->$op([$name]);
}
$this->setProcessedExtension($type, $op, $name);
......
......@@ -82,6 +82,7 @@ public function setDefault($name) {
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 @@ public function install(array $theme_list, $install_dependencies = TRUE) {
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);
}
......
......@@ -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 @@ public function install(array $theme_list, $install_dependencies = TRUE);
* @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);
......
......@@ -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.
......
......@@ -32,7 +32,7 @@ public function testAdminTheme() {
$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 @@ public function testSevenAdminTheme() {
$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'));
......
......@@ -47,7 +47,7 @@ public function testBlockDemo() {
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);
......
......@@ -53,7 +53,7 @@ public function testBlockNotInHiddenRegion() {
$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();
......
......@@ -244,7 +244,7 @@ public function testBlock() {
*/
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 @@ public function testThemeName() {
$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 @@ public function testThemeAdminLink() {
* 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('<front>');
$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()));
......
......@@ -84,11 +84,11 @@ public function testBlockDemoUiPage() {
$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('<strong>Test theme</strong>');
\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');
}
......
......@@ -34,7 +34,7 @@ public function testNonDefaultBlockAdmin() {
$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.');
}
......
......@@ -143,7 +143,7 @@ protected function deleteTests() {
* 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.');
......
......@@ -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 @@ public function testNewDefaultThemeBlocks() {
// 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 @@ public function testNewDefaultThemeBlocks() {
// 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();
......
......@@ -192,7 +192,7 @@ public function testsBlockContentAddTypes() {
->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.
......
......@@ -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']);
}
/**
......
......@@ -204,9 +204,10 @@ public function testLoadingWithoutInternalButtons() {
* 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 @@ public function testExternalStylesheets() {
$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 @@ public function testExternalStylesheets() {
$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',
......
......@@ -272,7 +272,7 @@ public function testBuildContentsCssJSSetting() {
$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'));
......
......@@ -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']);
......
......@@ -41,7 +41,7 @@ protected function setUp() {
*/
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:
......
......@@ -65,7 +65,7 @@ protected function setUp() {
'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 = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment