Issue #3269143 by longwave, catch: Remove deprecated theme key stylesheets-remove
parent
367742e472
commit
b2f342135b
|
@ -162,16 +162,6 @@ class AssetResolver implements AssetResolverInterface {
|
||||||
// Sort CSS items, so that they appear in the correct order.
|
// Sort CSS items, so that they appear in the correct order.
|
||||||
uasort($css, 'static::sort');
|
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) {
|
if ($optimize) {
|
||||||
$css = \Drupal::service('asset.css.collection_optimizer')->optimize($css);
|
$css = \Drupal::service('asset.css.collection_optimizer')->optimize($css);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,6 @@ class ActiveTheme {
|
||||||
*/
|
*/
|
||||||
protected $extension;
|
protected $extension;
|
||||||
|
|
||||||
/**
|
|
||||||
* The stylesheets which are set to be removed by the theme.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $styleSheetsRemove;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The libraries provided by the theme.
|
* The libraries provided by the theme.
|
||||||
*
|
*
|
||||||
|
@ -109,7 +102,6 @@ class ActiveTheme {
|
||||||
'engine' => 'twig',
|
'engine' => 'twig',
|
||||||
'owner' => 'twig',
|
'owner' => 'twig',
|
||||||
'logo' => '',
|
'logo' => '',
|
||||||
'stylesheets_remove' => [],
|
|
||||||
'libraries' => [],
|
'libraries' => [],
|
||||||
'extension' => 'html.twig',
|
'extension' => 'html.twig',
|
||||||
'base_theme_extensions' => [],
|
'base_theme_extensions' => [],
|
||||||
|
@ -123,7 +115,6 @@ class ActiveTheme {
|
||||||
$this->path = $values['path'];
|
$this->path = $values['path'];
|
||||||
$this->engine = $values['engine'];
|
$this->engine = $values['engine'];
|
||||||
$this->owner = $values['owner'];
|
$this->owner = $values['owner'];
|
||||||
$this->styleSheetsRemove = $values['stylesheets_remove'];
|
|
||||||
$this->libraries = $values['libraries'];
|
$this->libraries = $values['libraries'];
|
||||||
$this->extension = $values['extension'];
|
$this->extension = $values['extension'];
|
||||||
$this->baseThemeExtensions = $values['base_theme_extensions'];
|
$this->baseThemeExtensions = $values['base_theme_extensions'];
|
||||||
|
@ -188,26 +179,6 @@ class ActiveTheme {
|
||||||
return $this->libraries;
|
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.
|
* Returns an array of base theme extension objects keyed by name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -179,9 +179,6 @@ class ThemeInitialization implements ThemeInitializationInterface {
|
||||||
$values['logo'] = $theme->getPath() . '/logo.svg';
|
$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
|
// Prepare libraries overrides from this theme and ancestor themes. This
|
||||||
// allows child themes to easily remove CSS files from base themes and
|
// allows child themes to easily remove CSS files from base themes and
|
||||||
// modules.
|
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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:
|
theme_test.template_test:
|
||||||
path: '/theme-test/template-test'
|
path: '/theme-test/template-test'
|
||||||
defaults:
|
defaults:
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
<?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 $defaultTheme = 'stark';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setUp(): void {
|
|
||||||
parent::setUp();
|
|
||||||
\Drupal::service('theme_installer')->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('<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?');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -56,7 +56,7 @@ class ThemeInfoTest extends BrowserTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests stylesheets-remove.
|
* Tests libraries-override.
|
||||||
*/
|
*/
|
||||||
public function testStylesheets() {
|
public function testStylesheets() {
|
||||||
$this->themeInstaller->install(['test_basetheme', 'test_subtheme']);
|
$this->themeInstaller->install(['test_basetheme', 'test_subtheme']);
|
||||||
|
|
|
@ -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'
|
|
|
@ -110,7 +110,6 @@ class RegistryTest extends UnitTestCase {
|
||||||
'path' => 'core/modules/system/tests/themes/test_theme/test_theme.info.yml',
|
'path' => 'core/modules/system/tests/themes/test_theme/test_theme.info.yml',
|
||||||
'engine' => 'twig',
|
'engine' => 'twig',
|
||||||
'owner' => 'twig',
|
'owner' => 'twig',
|
||||||
'stylesheets_remove' => [],
|
|
||||||
'libraries_override' => [],
|
'libraries_override' => [],
|
||||||
'libraries_extend' => [],
|
'libraries_extend' => [],
|
||||||
'libraries' => [],
|
'libraries' => [],
|
||||||
|
@ -123,7 +122,6 @@ class RegistryTest extends UnitTestCase {
|
||||||
'path' => 'core/tests/fixtures/test_stable/test_stable.info.yml',
|
'path' => 'core/tests/fixtures/test_stable/test_stable.info.yml',
|
||||||
'engine' => 'twig',
|
'engine' => 'twig',
|
||||||
'owner' => 'twig',
|
'owner' => 'twig',
|
||||||
'stylesheets_remove' => [],
|
|
||||||
'libraries_override' => [],
|
'libraries_override' => [],
|
||||||
'libraries_extend' => [],
|
'libraries_extend' => [],
|
||||||
'libraries' => [],
|
'libraries' => [],
|
||||||
|
|
Loading…
Reference in New Issue