Skip to content
Snippets Groups Projects
Unverified Commit b2f34213 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3269143 by longwave, catch: Remove deprecated theme key stylesheets-remove

parent 367742e4
No related branches found
No related tags found
37 merge requests!12227Issue #3181946 by jonmcl, mglaman,!7471uncessary 5 files are moved from media-library folder to misc folder,!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!54479.5.x SF update,!5014Issue #3071143: Table Render Array Example Is Incorrect,!4868Issue #1428520: Improve menu parent link selection,!4289Issue #1344552 by marcingy, Niklas Fiekas, Ravi.J, aleevas, Eduardo Morales...,!4114Issue #2707291: Disable body-level scrolling when a dialog is open as a modal,!3630Issue #2815301 by Chi, DanielVeza, kostyashupenko, smustgrave: Allow to create...,!3291Issue #3336463: Rewrite rules for gzipped CSS and JavaScript aggregates never match,!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!3102Issue #3164428 by DonAtt, longwave, sahil.goyal, Anchal_gupta, alexpott: Use...,!2853#3274419 Makes BaseFieldOverride inherit the internal property from the base field.,!2719Issue #3110137: Remove Classy from core.,!2437Issue #3238257 by hooroomoo, Wim Leers: Fragment link pointing to <textarea>...,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!2062Issue #3246454: Add weekly granularity to views date sort,!1591Issue #3199697: Add JSON:API Translation experimental module,!1484Exposed filters get values from URL when Ajax is on,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1254Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS,!1162Issue #3100350: Unable to save '/' root path alias,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!925Issue #2339235: Remove taxonomy hard dependency on node module,!877Issue #2708101: Default value for link text is not saved,!873Issue #2875228: Site install not using batch API service,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!844Resolve #3036010 "Updaters",!712Issue #2909128: Autocomplete intermittent on Chrome Android,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -162,16 +162,6 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) {
// 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 @@ public function __construct(array $values) {
'engine' => 'twig',
'owner' => 'twig',
'logo' => '',
'stylesheets_remove' => [],
'libraries' => [],
'extension' => 'html.twig',
'base_theme_extensions' => [],
......@@ -123,7 +115,6 @@ public function __construct(array $values) {
$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 @@ public function getLibraries() {
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 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) {
$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 @@ 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
* 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;
}
}
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:
......
<?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 @@ protected function setUp(): void {
}
/**
* Tests stylesheets-remove.
* Tests libraries-override.
*/
public function testStylesheets() {
$this->themeInstaller->install(['test_basetheme', 'test_subtheme']);
......
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 @@ public function testGetRegistryForModule() {
'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 @@ public function testGetRegistryForModule() {
'path' => 'core/tests/fixtures/test_stable/test_stable.info.yml',
'engine' => 'twig',
'owner' => 'twig',
'stylesheets_remove' => [],
'libraries_override' => [],
'libraries_extend' => [],
'libraries' => [],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment