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.
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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() {
|
||||
$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',
|
||||
'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' => [],
|
||||
|
|
Loading…
Reference in New Issue