Skip to content
Snippets Groups Projects
Unverified Commit 9bb53f52 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3069052 by mikelutz, Berdir, longwave, ravi.shankar, voleger, lauriii,...

Issue #3069052 by mikelutz, Berdir, longwave, ravi.shankar, voleger, lauriii, catch, andypost: Properly deprecate the stylesheets-remove key from theme info.yml files
parent 5e395126
Branches
Tags
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards
......@@ -191,11 +191,18 @@ public function getLibraries() {
/**
* Returns the removed stylesheets by the theme.
*
* @return mixed
* 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.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* @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;
......
......@@ -182,7 +182,7 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) {
$values['logo'] = $theme->getPath() . '/logo.svg';
}
// @todo Remove in Drupal 9.0.x.
// @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
......@@ -312,6 +312,10 @@ protected function resolveStyleSheetPlaceholders($css_file) {
/**
* 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
......@@ -320,7 +324,9 @@ protected function resolveStyleSheetPlaceholders($css_file) {
* @return string[]
* The list of stylesheets-remove specified in the *.info.yml file.
*
* @todo Remove in Drupal 9.0.x.
* @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.
......@@ -330,6 +336,7 @@ protected function prepareStylesheetsRemove(Extension $theme, $base_themes) {
// 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;
......@@ -339,6 +346,7 @@ protected function prepareStylesheetsRemove(Extension $theme, $base_themes) {
// 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;
......
<?php
namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the legacy stylesheets-remove key.
*
* @group system
* @group legacy
*/
class LegacyStyleSheetsRemoveTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
\Drupal::service('theme_installer')->install(['test_legacy_stylesheets_remove']);
}
/**
* Tests the stylesheets-remove key.
*
* @throws \Behat\Mink\Exception\ExpectationException
*
* @expectedDeprecation 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
*/
public function testStyleSheetsRemove() {
\Drupal::configFactory()->getEditable('system.theme')->set('default', 'classy')->save();
$this->drupalGet('<front>');
$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('<front>');
$this->assertSession()->responseNotContains('css/components/action-links.css?');
$this->assertSession()->responseContains('css/components/breadcrumb.css?');
}
}
......@@ -7,8 +7,6 @@ hidden: true
libraries:
- test_basetheme/global-styling
stylesheets-remove:
- '@theme_test/css/base-remove.css'
libraries-override:
core/drupal.dialog:
js:
......@@ -17,6 +15,10 @@ libraries-override:
css:
component:
assets/vendor/farbtastic/farbtastic.css: css/farbtastic.css
theme_test/theme_stylesheets_override_and_remove_test:
css:
base:
css/base-remove.css: false
libraries-extend:
classy/base:
......
name: 'Theme Legacy Test Stylesheets Remove'
type: theme
description: 'Test theme using legacy stylesheets-remove.'
version: VERSION
core: 8.x
base theme: classy
libraries: { }
stylesheets-remove:
- '@classy/css/components/action-links.css'
......@@ -5,10 +5,15 @@ version: VERSION
base theme: test_basetheme
libraries:
- test_subtheme/global-styling
stylesheets-remove:
- '@theme_test/css/sub-remove.css'
- '@test_basetheme/base-add.sub-remove.css'
libraries-override:
theme_test/theme_stylesheets_override_and_remove_test:
css:
base:
css/sub-remove.css: false
test_basetheme/global-styling:
css:
base:
base-add.sub-remove.css: false
libraries-extend:
classy/base:
- test_subtheme/global-styling
......@@ -14,8 +14,6 @@ description: 'Theme for testing the theme system'
version: VERSION
base theme: classy
logo: images/logo2.svg
stylesheets-remove:
- '@stable/css/system/components/js.module.css'
libraries:
- test_theme/global-styling
libraries-override:
......@@ -36,6 +34,10 @@ libraries-override:
css:
component:
css/components/dialog.css: false
system/base:
css:
component:
/core/themes/stable/css/system/components/js.module.css: false
# It works for JS as well.
core/jquery:
js:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment