From 3fc595ad1677a69678149c239f0e32608d9181c6 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 25 Apr 2022 17:12:59 +0100 Subject: [PATCH] Issue #3269154 by longwave: Remove BC layers from the theme system --- .../Core/Render/MainContent/HtmlRenderer.php | 6 +----- core/lib/Drupal/Core/Theme/Registry.php | 18 ------------------ .../Drupal/Core/Theme/ThemeInitialization.php | 16 +++------------- .../src/Functional/Theme/EngineNyanCatTest.php | 7 ------- .../themes/engines/nyan_cat/nyan_cat.engine | 10 ---------- .../Drupal/Tests/Core/Theme/RegistryTest.php | 18 ++---------------- 6 files changed, 6 insertions(+), 69 deletions(-) diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 460f5436602..d4905fb592a 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -108,7 +108,7 @@ class HtmlRenderer implements MainContentRendererInterface { * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager * The theme manager. */ - public function __construct(TitleResolverInterface $title_resolver, PluginManagerInterface $display_variant_manager, EventDispatcherInterface $event_dispatcher, ModuleHandlerInterface $module_handler, RendererInterface $renderer, RenderCacheInterface $render_cache, array $renderer_config, ThemeManagerInterface $theme_manager = NULL) { + public function __construct(TitleResolverInterface $title_resolver, PluginManagerInterface $display_variant_manager, EventDispatcherInterface $event_dispatcher, ModuleHandlerInterface $module_handler, RendererInterface $renderer, RenderCacheInterface $render_cache, array $renderer_config, ThemeManagerInterface $theme_manager) { $this->titleResolver = $title_resolver; $this->displayVariantManager = $display_variant_manager; $this->eventDispatcher = $event_dispatcher; @@ -116,10 +116,6 @@ class HtmlRenderer implements MainContentRendererInterface { $this->renderer = $renderer; $this->renderCache = $render_cache; $this->rendererConfig = $renderer_config; - if ($theme_manager === NULL) { - @trigger_error('Calling ' . __METHOD__ . ' without the $theme_manager argument is deprecated in drupal:9.1.0 and will be required in drupal:10.0.0. See https://www.drupal.org/node/3159762', E_USER_DEPRECATED); - $theme_manager = \Drupal::service('theme.manager'); - } $this->themeManager = $theme_manager; } diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 9a4182919a5..a23f87214fd 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -812,22 +812,4 @@ class Registry implements DestructableInterface { return $grouped_functions; } - /** - * Wraps drupal_get_path(). - * - * @param string $module - * The name of the item for which the path is requested. - * - * @return string - * - * @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use - * \Drupal\Core\Extension\ExtensionList::getPath() instead. - * - * @see https://www.drupal.org/node/2940438 - */ - protected function getPath($module) { - @trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Extension\ExtensionList::getPath() instead. See https://www.drupal.org/node/2940438', E_USER_DEPRECATED); - return $this->moduleList->getPath($module); - } - } diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index d9c3830143a..e451d73abff 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -138,20 +138,10 @@ class ThemeInitialization implements ThemeInitializationInterface { if ($theme_engine = $active_theme->getEngine()) { // Include the engine. include_once $this->root . '/' . $active_theme->getOwner(); - - if (function_exists($theme_engine . '_init')) { - @trigger_error('THEME_ENGINE_init() is deprecated in drupal:9.3.0 and removed in drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3246978', E_USER_DEPRECATED); - foreach ($active_theme->getBaseThemeExtensions() as $base) { - call_user_func($theme_engine . '_init', $base); - } - call_user_func($theme_engine . '_init', $active_theme->getExtension()); - } - else { - foreach ($active_theme->getBaseThemeExtensions() as $base) { - $base->load(); - } - $active_theme->getExtension()->load(); + foreach ($active_theme->getBaseThemeExtensions() as $base) { + $base->load(); } + $active_theme->getExtension()->load(); } else { // include non-engine theme files diff --git a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php index 0b8269a2cd3..7a227da1ddb 100644 --- a/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php @@ -30,15 +30,8 @@ class EngineNyanCatTest extends BrowserTestBase { /** * Ensures a theme's template is overridable based on the 'template' filename. - * - * @group legacy - * - * @todo https://www.drupal.org/project/drupal/issues/3246981 Remove - * nyan_cat_init() and the legacy group and expected deprecation from this - * test. */ public function testTemplateOverride() { - $this->expectDeprecation('THEME_ENGINE_init() is deprecated in drupal:9.3.0 and removed in drupal:10.0.0. There is no replacement. See https://www.drupal.org/node/3246978'); $this->config('system.theme') ->set('default', 'test_theme_nyan_cat_engine') ->save(); diff --git a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine index a99c465d369..44a50da8ade 100644 --- a/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine +++ b/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine @@ -7,16 +7,6 @@ use Drupal\Core\Extension\Extension; -/** - * Includes .theme file from themes. - * - * @param \Drupal\Core\Extension\Extension $theme - * The theme extension object. - */ -function nyan_cat_init(Extension $theme) { - $theme->load(); -} - /** * Implements hook_theme(). */ diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index f81a8f6d748..d18c3567756 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -89,7 +89,8 @@ class RegistryTest extends UnitTestCase { $this->themeInitialization = $this->createMock('Drupal\Core\Theme\ThemeInitializationInterface'); $this->themeManager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface'); $this->moduleList = $this->createMock(ModuleExtensionList::class); - $this->setupTheme(); + $this->registry = new Registry($this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization, NULL, NULL, $this->moduleList); + $this->registry->setThemeManager($this->themeManager); } /** @@ -484,21 +485,6 @@ class RegistryTest extends UnitTestCase { return $data; } - protected function setupTheme() { - $this->registry = $this->getMockBuilder(Registry::class) - ->onlyMethods(['getPath']) - ->setConstructorArgs([$this->root, $this->cache, $this->lock, $this->moduleHandler, $this->themeHandler, $this->themeInitialization, NULL, NULL, $this->moduleList]) - ->getMock(); - $this->registry->expects($this->any()) - ->method('getPath') - ->willReturnCallback(function ($module) { - if ($module == 'theme_test') { - return 'core/modules/system/tests/modules/theme_test'; - } - }); - $this->registry->setThemeManager($this->themeManager); - } - } namespace Drupal\Core\Theme;