Skip to content

Commit 2f16ed9

Browse files
committed
Issue #2972153 by dimitriskr, alexpott, smustgrave, andypost, kostyashupenko: Deprecate ThemeHandlerInterface::getBaseThemes and remove usages from core
1 parent 31251cf commit 2f16ed9

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

lib/Drupal/Core/Extension/ThemeExtensionList.php

+6
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,14 @@ protected function fillInSubThemeData(array &$themes, array $sub_themes) {
210210
* @return array
211211
* Returns an array of all of the theme's ancestors; the first element's
212212
* value will be NULL if an error occurred.
213+
*
214+
* @deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. There
215+
* is no direct replacement.
216+
*
217+
* @see https://www.drupal.org/node/3413187
213218
*/
214219
public function getBaseThemes(array $themes, $theme) {
220+
@trigger_error("\Drupal\Core\Extension\ThemeExtensionList::getBaseThemes() is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. There is no direct replacement. See https://www.drupal.org/node/3413187", E_USER_DEPRECATED);
215221
return $this->doGetBaseThemes($themes, $theme);
216222
}
217223

lib/Drupal/Core/Extension/ThemeHandler.php

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function rebuildThemeData() {
133133
* {@inheritdoc}
134134
*/
135135
public function getBaseThemes(array $themes, $theme) {
136+
@trigger_error("\Drupal\Core\Extension\ThemeHandlerInterface::getBaseThemes() is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. There is no direct replacement. See https://www.drupal.org/node/3413187", E_USER_DEPRECATED);
136137
return $this->themeList->getBaseThemes($themes, $theme);
137138
}
138139

lib/Drupal/Core/Extension/ThemeHandlerInterface.php

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ public function rebuildThemeData();
9898
* @return array
9999
* Returns an array of all of the theme's ancestors; the first element's
100100
* value will be NULL if an error occurred.
101+
*
102+
* @deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. There
103+
* is no direct replacement.
104+
*
105+
* @see https://www.drupal.org/node/3413187
101106
*/
102107
public function getBaseThemes(array $themes, $theme);
103108

tests/Drupal/Tests/Core/Extension/ThemeExtensionListTest.php

+32-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ public function testRebuildThemeDataWithThemeParents() {
116116
* @param array $expected
117117
* The expected base themes.
118118
*
119-
* @dataProvider providerTestGetBaseThemes
119+
* @dataProvider providerTestDoGetBaseThemes
120+
*
121+
* @group legacy
120122
*/
121123
public function testGetBaseThemes(array $themes, $theme, array $expected) {
122124
// Mocks and stubs.
@@ -126,18 +128,45 @@ public function testGetBaseThemes(array $themes, $theme, array $expected) {
126128
$theme_engine_list = $this->prophesize(ThemeEngineExtensionList::class);
127129
$theme_listing = new ThemeExtensionList($this->root, 'theme', new NullBackend('test'), new InfoParser($this->root), $module_handler->reveal(), $state, $config_factory, $theme_engine_list->reveal(), 'test');
128130

131+
$this->expectDeprecation("\Drupal\Core\Extension\ThemeExtensionList::getBaseThemes() is deprecated in drupal:10.3.0 and is removed from drupal:12.0.0. There is no direct replacement. See https://www.drupal.org/node/3413187");
129132
$base_themes = $theme_listing->getBaseThemes($themes, $theme);
130133

131134
$this->assertEquals($expected, $base_themes);
132135
}
133136

134137
/**
135-
* Provides test data for testGetBaseThemes.
138+
* Tests getting the base themes for a set of defined themes.
139+
*
140+
* @param array $themes
141+
* An array of available themes, keyed by the theme name.
142+
* @param string $theme
143+
* The theme name to find all its base themes.
144+
* @param array $expected
145+
* The expected base themes.
146+
*
147+
* @dataProvider providerTestDoGetBaseThemes
148+
*/
149+
public function testDoGetBaseThemes(array $themes, $theme, array $expected): void {
150+
// Mocks and stubs.
151+
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
152+
$state = new State(new KeyValueMemoryFactory());
153+
$config_factory = $this->getConfigFactoryStub([]);
154+
$theme_engine_list = $this->prophesize(ThemeEngineExtensionList::class);
155+
$theme_listing = new ThemeExtensionList($this->root, 'theme', new NullBackend('test'), new InfoParser($this->root), $module_handler->reveal(), $state, $config_factory, $theme_engine_list->reveal(), 'test');
156+
157+
$method_to_test = (new \ReflectionObject($theme_listing))->getMethod('doGetBaseThemes');
158+
$base_themes = $method_to_test->invoke($theme_listing, $themes, $theme);
159+
160+
$this->assertEquals($expected, $base_themes);
161+
}
162+
163+
/**
164+
* Provides test data for testDoGetBaseThemes.
136165
*
137166
* @return array
138167
* An array of theme test data.
139168
*/
140-
public static function providerTestGetBaseThemes() {
169+
public static function providerTestDoGetBaseThemes() {
141170
$data = [];
142171

143172
// Tests a theme without any base theme.

0 commit comments

Comments
 (0)