Unverified Commit d57f7ebc authored by alexpott's avatar alexpott
Browse files

Issue #3113053 by hash6, Hardik_Patel_12, longwave, alexpott: Remove...

Issue #3113053 by hash6, Hardik_Patel_12, longwave, alexpott: Remove $baseThemes BC layer from \Drupal\Core\Theme\ActiveTheme
parent fbcb162e
......@@ -47,17 +47,6 @@ class ActiveTheme {
*/
protected $owner;
/**
* An array of base theme active theme objects keyed by name.
*
* @var static[]
*
* @deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
* $this->baseThemeExtensions instead.
*
* @see https://www.drupal.org/node/3019948
*/
protected $baseThemes;
/**
* An array of base theme extension objects keyed by name.
......@@ -138,13 +127,6 @@ public function __construct(array $values) {
$this->libraries = $values['libraries'];
$this->extension = $values['extension'];
$this->baseThemeExtensions = $values['base_theme_extensions'];
if (!empty($values['base_themes']) && empty($this->baseThemeExtensions)) {
@trigger_error("The 'base_themes' key is deprecated in Drupal 8.7.0 and support for it will be removed in Drupal 9.0.0. Use 'base_theme_extensions' instead. See https://www.drupal.org/node/3019948", E_USER_DEPRECATED);
foreach ($values['base_themes'] as $base_theme) {
$this->baseThemeExtensions[$base_theme->getName()] = $base_theme->getExtension();
}
}
$this->regions = $values['regions'];
$this->librariesOverride = $values['libraries_override'];
$this->librariesExtend = $values['libraries_extend'];
......@@ -219,27 +201,6 @@ public function getStyleSheetsRemove() {
return $this->styleSheetsRemove;
}
/**
* Returns an array of base theme active theme objects keyed by name.
*
* The order starts with the base theme of $this and ends with the root of
* the dependency chain.
*
* @return static[]
*
* @deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead.
*
* @see https://www.drupal.org/node/3019948
*/
public function getBaseThemes() {
@trigger_error('\Drupal\Core\Theme\ActiveTheme::getBaseThemes() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead. See https://www.drupal.org/node/3019948', E_USER_DEPRECATED);
/** @var \Drupal\Core\Theme\ThemeInitialization $theme_initialisation */
$theme_initialisation = \Drupal::service('theme.initialization');
$base_themes = array_combine(array_keys($this->baseThemeExtensions), array_keys($this->baseThemeExtensions));
return array_map([$theme_initialisation, 'getActiveThemeByName'], $base_themes);
}
/**
* Returns an array of base theme extension objects keyed by name.
*
......
<?php
namespace Drupal\KernelTests\Core\Theme;
use Drupal\Core\Theme\ActiveTheme;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests legacy code in ActiveTheme.
*
* @coversDefaultClass \Drupal\Core\Theme\ActiveTheme
* @group Theme
* @group legacy
*/
class ActiveThemeLegacyTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = ['system'];
/**
* Tests \Drupal\Core\Theme\ActiveTheme::getBaseThemes() deprecation.
*
* @covers ::getBaseThemes
* @expectedDeprecation \Drupal\Core\Theme\ActiveTheme::getBaseThemes() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead. See https://www.drupal.org/node/3019948
*/
public function testGetBaseThemes() {
$this->container->get('theme_installer')->install(['test_subsubtheme']);
$this->config('system.theme')->set('default', 'test_subsubtheme')->save();
$active_theme = \Drupal::theme()->getActiveTheme();
// Ensure that active theme representations of base themes can be retrieved.
$base_themes = $active_theme->getBaseThemes();
$this->assertInstanceOf(ActiveTheme::class, $base_themes['test_subtheme']);
$this->assertSame(['test_subtheme', 'test_basetheme'], array_keys($base_themes));
// Ensure that we can get base themes from base themes.
$test_subtheme_base_themes = $base_themes['test_subtheme']->getBaseThemes();
$this->assertSame(['test_basetheme'], array_keys($test_subtheme_base_themes));
$this->assertEmpty($test_subtheme_base_themes['test_basetheme']->getBaseThemes());
}
/**
* Tests BC layer in constructor.
*
* @covers ::__construct
* @expectedDeprecation The 'base_themes' key is deprecated in Drupal 8.7.0 and support for it will be removed in Drupal 9.0.0. Use 'base_theme_extensions' instead. See https://www.drupal.org/node/3019948
*/
public function testConstructor() {
$themes = $this->container->get('extension.list.theme')->getList();
$values = [
'name' => $themes['test_basetheme']->getName(),
'extension' => $themes['test_basetheme'],
];
$base_active_theme = new ActiveTheme($values);
$values = [
'name' => $themes['test_subtheme']->getName(),
'extension' => $themes['test_subtheme'],
'base_themes' => ['test_basetheme' => $base_active_theme],
];
$active_theme = new ActiveTheme($values);
$base_extensions = $active_theme->getBaseThemeExtensions();
$this->assertSame($base_extensions['test_basetheme'], $themes['test_basetheme']);
$this->assertSame(['test_basetheme'], array_keys($base_extensions));
}
}
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