function ThemeInitialization::prepareStylesheetsRemove

Same name in other branches
  1. 9 core/lib/Drupal/Core/Theme/ThemeInitialization.php \Drupal\Core\Theme\ThemeInitialization::prepareStylesheetsRemove()

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.

@todo Remove in Drupal 10.0.x.

@internal

Parameters

\Drupal\Core\Extension\Extension $theme: The theme extension object.

\Drupal\Core\Extension\Extension[] $base_themes: An array of base themes.

Return value

string[] The list of stylesheets-remove specified in the *.info.yml file.

1 call to ThemeInitialization::prepareStylesheetsRemove()
ThemeInitialization::getActiveTheme in core/lib/Drupal/Core/Theme/ThemeInitialization.php
Builds up the active theme object from extensions.

File

core/lib/Drupal/Core/Theme/ThemeInitialization.php, line 331

Class

ThemeInitialization
Provides the theme initialization logic.

Namespace

Drupal\Core\Theme

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.