Commit dd3ee4c7 authored by catch's avatar catch

Issue #2635784 by Manuel Garcia, sidharthap, cilefen, veerasekar89, gambry,...

Issue #2635784 by Manuel Garcia, sidharthap, cilefen, veerasekar89, gambry, catch, alexpott, Cottser, dawehner, joelpittet: Deprecate ThemeHandler::setDefault() in favour of configuration and replace usages
parent 98889d33
......@@ -165,6 +165,9 @@ public function getDefault();
* The new default theme.
*
* @return $this
*
* @deprecated in Drupal 8.2.x-dev and will be removed before Drupal 9.0.0.
* Use \Drupal::config('system.theme')->set('default', $theme)->save().
*/
public function setDefault($theme);
......
......@@ -481,12 +481,12 @@ public function testUninstallTheme() {
$theme_handler = \Drupal::service('theme_handler');
$theme_handler->install(['seven']);
$theme_handler->setDefault('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');
$theme_handler->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$theme_handler->uninstall(['seven']);
// Ensure that the block configuration does not exist anymore.
......
......@@ -201,7 +201,7 @@ function testExternalStylesheets() {
$theme_handler = \Drupal::service('theme_handler');
// Case 1: Install theme which has an absolute external CSS URL.
$theme_handler->install(['test_ckeditor_stylesheets_external']);
$theme_handler->setDefault('test_ckeditor_stylesheets_external');
$this->config('system.theme')->set('default', 'test_ckeditor_stylesheets_external')->save();
$expected = [
'https://fonts.googleapis.com/css?family=Open+Sans',
];
......@@ -209,7 +209,7 @@ function testExternalStylesheets() {
// Case 2: Install theme which has an external protocol-relative CSS URL.
$theme_handler->install(['test_ckeditor_stylesheets_protocol_relative']);
$theme_handler->setDefault('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',
];
......@@ -217,7 +217,7 @@ function testExternalStylesheets() {
// Case 3: Install theme which has a relative CSS URL.
$theme_handler->install(['test_ckeditor_stylesheets_relative']);
$theme_handler->setDefault('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',
];
......
......@@ -273,7 +273,7 @@ function testBuildContentsCssJSSetting() {
// Enable the Bartik theme, which specifies a CKEditor stylesheet.
\Drupal::service('theme_handler')->install(['bartik']);
\Drupal::service('theme_handler')->setDefault('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'));
$expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/components/table.css'));
......
......@@ -123,7 +123,7 @@ function testFieldItemListView() {
$items = $this->entity->get($this->fieldName);
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
// No display settings: check that default display settings are used.
$build = $items->view();
......
......@@ -65,7 +65,7 @@ protected function setUp() {
// Use Classy theme for testing markup output.
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->installEntitySchema('entity_test');
// Grant the 'view test entity' permission.
$this->installConfig(array('user'));
......
......@@ -107,7 +107,7 @@ protected function setUp() {
// Use Classy theme for testing markup output.
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
......
......@@ -31,7 +31,7 @@ public function testIntegerFormatter() {
*/
public function testIntegerFormatterWithSettings() {
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'integer';
$formatter = array(
'type' => 'number_integer',
......@@ -74,7 +74,7 @@ public function testFloatFormatter() {
*/
public function testFloatFormatterWithSettings() {
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'float';
$formatter = array(
'type' => 'number_decimal',
......@@ -124,7 +124,7 @@ public function testFloatFormatterWithScale() {
*/
public function testFloatFormatterWithScaleExercised() {
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'float';
$formatter = array(
'type' => 'number_decimal',
......@@ -162,7 +162,7 @@ public function testDecimalFormatter() {
*/
public function testDecimalFormatterWithSettings() {
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->fieldType = 'decimal';
$formatter = array(
'type' => 'number_decimal',
......
......@@ -123,7 +123,7 @@ protected function testSiteMaintenance() {
// Regression test to check if title displays in Bartik on maintenance page.
\Drupal::service('theme_handler')->install(array('bartik'));
\Drupal::service('theme_handler')->setDefault('bartik');
$this->config('system.theme')->set('default', 'bartik')->save();
// Logout and verify that offline message is displayed in Bartik.
$this->drupalLogout();
......
......@@ -305,7 +305,7 @@ function testSwitchDefaultTheme() {
$theme_handler = \Drupal::service('theme_handler');
// First, install Stark and set it as the default theme programmatically.
$theme_handler->install(array('stark'));
$theme_handler->setDefault('stark');
$this->config('system.theme')->set('default', 'stark')->save();
// Install Bartik and set it as the default theme.
$theme_handler->install(array('bartik'));
......
......@@ -84,7 +84,7 @@ function testStylesheets() {
*/
public function testChanges() {
$this->themeHandler->install(array('test_theme'));
$this->themeHandler->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
$this->themeManager->resetActiveTheme();
$active_theme = $this->themeManager->getActiveTheme();
......
......@@ -298,7 +298,7 @@ public function testRegionClass() {
* when needed.
*/
public function testSuggestionPreprocessForDefaults() {
\Drupal::service('theme_handler')->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
// Test with both an unprimed and primed theme registry.
drupal_theme_rebuild();
for ($i = 0; $i < 2; $i++) {
......
......@@ -26,7 +26,7 @@ function testTwigDebugMarkup() {
$renderer = $this->container->get('renderer');
$extension = twig_extension();
\Drupal::service('theme_handler')->install(array('test_theme'));
\Drupal::service('theme_handler')->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
$this->drupalCreateContentType(array('type' => 'page'));
// Enable debug, rebuild the service container, and clear all caches.
$parameters = $this->container->getParameter('twig.config');
......
......@@ -78,7 +78,7 @@ function testTwigCacheOverride() {
$extension = twig_extension();
$theme_handler = $this->container->get('theme_handler');
$theme_handler->install(array('test_theme'));
$theme_handler->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
// The registry still works on theme globals, so set them here.
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->getActiveThemeByName('test_theme'));
......
......@@ -49,7 +49,7 @@ protected function setUp() {
// Setup test_theme.
\Drupal::service('theme_handler')->install(array('test_theme'));
\Drupal::service('theme_handler')->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
// Create and log in as admin.
$this->adminUser = $this->drupalCreateUser(array(
......
......@@ -39,7 +39,7 @@ public function testCurrentTheme() {
$this->assertTrue($condition_negated->execute());
// Set the expected theme to be used.
\Drupal::service('theme_handler')->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
\Drupal::theme()->resetActiveTheme();
$this->assertTrue($condition->execute());
......
......@@ -83,7 +83,7 @@ function testThemeTableWithEmptyMessage() {
// Enable the Classy theme.
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
$this->render($table);
$this->removeWhiteSpace();
......
......@@ -22,7 +22,7 @@ class MessageTest extends KernelTestBase {
function testMessages() {
// Enable the Classy theme.
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->config('system.theme')->set('default', 'classy')->save();
drupal_set_message('An error occurred', 'error');
drupal_set_message('But then something nice happened');
......
......@@ -150,7 +150,7 @@ public function testThemeRegistryAlterByTheme() {
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
$theme_handler = \Drupal::service('theme_handler');
$theme_handler->install(['test_theme']);
$theme_handler->setDefault('test_theme');
$this->config('system.theme')->set('default', 'test_theme')->save();
$registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme');
$registry->setThemeManager(\Drupal::theme());
......
......@@ -47,7 +47,7 @@ protected function setUp() {
*/
public function testStableIsDefault() {
$this->themeHandler->install(['test_stable']);
$this->themeHandler->setDefault('test_stable');
$this->config('system.theme')->set('default', 'test_stable')->save();
$theme = $this->themeManager->getActiveTheme();
/** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
$base_themes = $theme->getBaseThemes();
......@@ -60,7 +60,7 @@ public function testStableIsDefault() {
*/
public function testWildWest() {
$this->themeHandler->install(['test_wild_west']);
$this->themeHandler->setDefault('test_wild_west');
$this->config('system.theme')->set('default', 'test_wild_west')->save();
$theme = $this->themeManager->getActiveTheme();
/** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
$base_themes = $theme->getBaseThemes();
......
......@@ -145,7 +145,7 @@ function testUninstallDefault() {
$name = 'stark';
$other_name = 'bartik';
$this->themeInstaller()->install(array($name, $other_name));
$this->themeHandler()->setDefault($name);
$this->config('system.theme')->set('default', $name)->save();
$themes = $this->themeHandler()->listInfo();
$this->assertTrue(isset($themes[$name]));
......
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