diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php index 7f4b110bc52a..94343886ced2 100644 --- a/core/lib/Drupal/Core/Asset/AssetResolver.php +++ b/core/lib/Drupal/Core/Asset/AssetResolver.php @@ -162,16 +162,6 @@ class AssetResolver implements AssetResolverInterface { // Sort CSS items, so that they appear in the correct order. uasort($css, 'static::sort'); - // Allow themes to remove CSS files by CSS files full path and file name. - // @todo Remove in Drupal 9.0.x. - if ($stylesheet_remove = $theme_info->getStyleSheetsRemove()) { - foreach ($css as $key => $options) { - if (isset($stylesheet_remove[$key])) { - unset($css[$key]); - } - } - } - if ($optimize) { $css = \Drupal::service('asset.css.collection_optimizer')->optimize($css); } diff --git a/core/lib/Drupal/Core/Theme/ActiveTheme.php b/core/lib/Drupal/Core/Theme/ActiveTheme.php index 9da3e7d14d97..ff1b89e9b970 100644 --- a/core/lib/Drupal/Core/Theme/ActiveTheme.php +++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php @@ -62,13 +62,6 @@ class ActiveTheme { */ protected $extension; - /** - * The stylesheets which are set to be removed by the theme. - * - * @var array - */ - protected $styleSheetsRemove; - /** * The libraries provided by the theme. * @@ -109,7 +102,6 @@ class ActiveTheme { 'engine' => 'twig', 'owner' => 'twig', 'logo' => '', - 'stylesheets_remove' => [], 'libraries' => [], 'extension' => 'html.twig', 'base_theme_extensions' => [], @@ -123,7 +115,6 @@ class ActiveTheme { $this->path = $values['path']; $this->engine = $values['engine']; $this->owner = $values['owner']; - $this->styleSheetsRemove = $values['stylesheets_remove']; $this->libraries = $values['libraries']; $this->extension = $values['extension']; $this->baseThemeExtensions = $values['base_theme_extensions']; @@ -188,26 +179,6 @@ class ActiveTheme { return $this->libraries; } - /** - * Returns the removed stylesheets by the theme. - * - * This method is used as a BC layer to access the contents of the deprecated - * stylesheets-remove key in theme info.yml files. It will be removed once it - * is no longer needed in Drupal 10. - * - * @return mixed - * The removed stylesheets. - * - * @see https://www.drupal.org/node/2497313 - * - * @todo Remove in Drupal 10.0.x. - * - * @internal - */ - public function getStyleSheetsRemove() { - return $this->styleSheetsRemove; - } - /** * Returns an array of base theme extension objects keyed by name. * diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index e451d73abff2..ee52887b59d1 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -179,9 +179,6 @@ class ThemeInitialization implements ThemeInitializationInterface { $values['logo'] = $theme->getPath() . '/logo.svg'; } - // @todo Remove in Drupal 10.0.x. - $values['stylesheets_remove'] = $this->prepareStylesheetsRemove($theme, $base_themes); - // Prepare libraries overrides from this theme and ancestor themes. This // allows child themes to easily remove CSS files from base themes and // modules. @@ -306,50 +303,4 @@ class ThemeInitialization implements ThemeInitializationInterface { } } - /** - * Prepares stylesheets-remove specified in the *.info.yml file. - * - * This method is used as a BC layer to access the contents of the deprecated - * stylesheets-remove key in theme info.yml files. It will be removed once it - * is no longer needed in Drupal 10. - * - * @param \Drupal\Core\Extension\Extension $theme - * The theme extension object. - * @param \Drupal\Core\Extension\Extension[] $base_themes - * An array of base themes. - * - * @return string[] - * The list of stylesheets-remove specified in the *.info.yml file. - * - * @todo Remove in Drupal 10.0.x. - * - * @internal - */ - protected function prepareStylesheetsRemove(Extension $theme, $base_themes) { - // Prepare stylesheets from this theme as well as all ancestor themes. - // We work it this way so that we can have child themes remove CSS files - // easily from parent. - $stylesheets_remove = []; - // Grab stylesheets from base theme. - foreach ($base_themes as $base) { - if (!empty($base->info['stylesheets-remove'])) { - @trigger_error('The theme info key stylesheets-remove implemented by theme ' . $base->getName() . ' is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/2497313', E_USER_DEPRECATED); - foreach ($base->info['stylesheets-remove'] as $css_file) { - $css_file = $this->resolveStyleSheetPlaceholders($css_file); - $stylesheets_remove[$css_file] = $css_file; - } - } - } - - // Add stylesheets used by this theme. - if (!empty($theme->info['stylesheets-remove'])) { - @trigger_error('The theme info key stylesheets-remove implemented by theme ' . $theme->getName() . ' is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/2497313', E_USER_DEPRECATED); - foreach ($theme->info['stylesheets-remove'] as $css_file) { - $css_file = $this->resolveStyleSheetPlaceholders($css_file); - $stylesheets_remove[$css_file] = $css_file; - } - } - return $stylesheets_remove; - } - } diff --git a/core/modules/system/tests/modules/theme_test/theme_test.routing.yml b/core/modules/system/tests/modules/theme_test/theme_test.routing.yml index d08c5ba4d855..1299fe9562e6 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.routing.yml +++ b/core/modules/system/tests/modules/theme_test/theme_test.routing.yml @@ -1,10 +1,3 @@ -theme_test.info_stylesheets: - path: '/theme-test/info/stylesheets' - defaults: - _controller: '\Drupal\theme_test\ThemeTestController::testInfoStylesheets' - requirements: - _access: 'TRUE' - theme_test.template_test: path: '/theme-test/template-test' defaults: diff --git a/core/modules/system/tests/src/Functional/Theme/LegacyStyleSheetsRemoveTest.php b/core/modules/system/tests/src/Functional/Theme/LegacyStyleSheetsRemoveTest.php deleted file mode 100644 index fde9b59b2326..000000000000 --- a/core/modules/system/tests/src/Functional/Theme/LegacyStyleSheetsRemoveTest.php +++ /dev/null @@ -1,45 +0,0 @@ -install(['test_legacy_stylesheets_remove']); - } - - /** - * Tests the stylesheets-remove key. - * - * @throws \Behat\Mink\Exception\ExpectationException - */ - public function testStyleSheetsRemove() { - $this->expectDeprecation('The theme info key stylesheets-remove implemented by theme test_legacy_stylesheets_remove is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/2497313'); - \Drupal::configFactory()->getEditable('system.theme')->set('default', 'classy')->save(); - $this->drupalGet(''); - $this->assertSession()->responseContains('css/components/action-links.css?'); - $this->assertSession()->responseContains('css/components/breadcrumb.css?'); - \Drupal::configFactory()->getEditable('system.theme')->set('default', 'test_legacy_stylesheets_remove')->save(); - $this->drupalGet(''); - $this->assertSession()->responseNotContains('css/components/action-links.css?'); - $this->assertSession()->responseContains('css/components/breadcrumb.css?'); - } - -} diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php index 93242b6d8eba..4437f0b3c41a 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php @@ -56,7 +56,7 @@ class ThemeInfoTest extends BrowserTestBase { } /** - * Tests stylesheets-remove. + * Tests libraries-override. */ public function testStylesheets() { $this->themeInstaller->install(['test_basetheme', 'test_subtheme']); diff --git a/core/modules/system/tests/themes/test_legacy_stylesheets_remove/test_legacy_stylesheets_remove.info.yml b/core/modules/system/tests/themes/test_legacy_stylesheets_remove/test_legacy_stylesheets_remove.info.yml deleted file mode 100644 index 6cd835e4d591..000000000000 --- a/core/modules/system/tests/themes/test_legacy_stylesheets_remove/test_legacy_stylesheets_remove.info.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: 'Theme Legacy Test Stylesheets Remove' -type: theme -description: 'Test theme using legacy stylesheets-remove.' -version: VERSION -base theme: classy -package: Testing -libraries: { } -stylesheets-remove: - - '@classy/css/components/action-links.css' diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index d18c35677566..3cc86665c4c3 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -110,7 +110,6 @@ class RegistryTest extends UnitTestCase { 'path' => 'core/modules/system/tests/themes/test_theme/test_theme.info.yml', 'engine' => 'twig', 'owner' => 'twig', - 'stylesheets_remove' => [], 'libraries_override' => [], 'libraries_extend' => [], 'libraries' => [], @@ -123,7 +122,6 @@ class RegistryTest extends UnitTestCase { 'path' => 'core/tests/fixtures/test_stable/test_stable.info.yml', 'engine' => 'twig', 'owner' => 'twig', - 'stylesheets_remove' => [], 'libraries_override' => [], 'libraries_extend' => [], 'libraries' => [],