Issue #3348848 by andypost, Purencool, daffie: Deprecate theme_get_registry()

merge-requests/3624/merge
Lauri Eskola 2023-03-28 10:43:07 +03:00
parent 8a924f778d
commit 0e8a558b4f
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
3 changed files with 22 additions and 1 deletions

View File

@ -87,13 +87,20 @@ const RESPONSIVE_PRIORITY_LOW = 'priority-low';
* @return array|\Drupal\Core\Utility\ThemeRegistry
* The complete theme registry array, or an instance of the
* Drupal\Core\Utility\ThemeRegistry class.
*
* @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
* theme.registry service methods get() or getRuntime() instead.
*
* @see https://www.drupal.org/node/3348850
*/
function theme_get_registry($complete = TRUE) {
$theme_registry = \Drupal::service('theme.registry');
if ($complete) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850', E_USER_DEPRECATED);
return $theme_registry->get();
}
else {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850', E_USER_DEPRECATED);
return $theme_registry->getRuntime();
}
}

View File

@ -547,7 +547,7 @@ function hook_preprocess(&$variables, $hook) {
}
if (!isset($hooks)) {
$hooks = theme_get_registry();
$hooks = \Drupal::service('theme.registry')->get();
}
// Determine the primary theme function argument.

View File

@ -272,4 +272,18 @@ class RegistryTest extends KernelTestBase {
$this->assertSame($hooks, $registry->get());
}
/**
* Tests deprecated theme_get_registry function.
*
* @see theme_get_registry()
* @group legacy
*/
public function testLegacyThemeGetRegistry() {
$registry = \Drupal::service('theme.registry');
$this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method get() instead. See https://www.drupal.org/node/3348850');
$this->assertEquals($registry->get(), theme_get_registry());
$this->expectDeprecation('theme_get_registry() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use theme.registry service method getRuntime() instead. See https://www.drupal.org/node/3348850');
$this->assertEquals($registry->getRuntime(), theme_get_registry(FALSE));
}
}