Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AssetResolverInterface.php

function AssetResolverInterface::getCssAssets

Returns the CSS assets for the current response's libraries.

It returns the CSS assets in order, according to the SMACSS categories specified in the assets' weights:

  • CSS_BASE
  • CSS_LAYOUT
  • CSS_COMPONENT
  • CSS_STATE
  • CSS_THEME

This ensures proper cascading of styles so themes can easily override module styles through CSS selectors.

Themes may replace module-defined CSS files by adding a stylesheet with the same filename. For example, themes/olivero/system-menus.css would replace modules/system/system-menus.css. This allows themes to override complete CSS files, rather than specific selectors, when necessary.

Also invokes hook_css_alter(), to allow CSS assets to be altered.

Parameters

\Drupal\Core\Asset\AttachedAssetsInterface $assets: The assets attached to the current response.

bool $optimize: Whether to apply the CSS asset collection optimizer, to return an optimized CSS asset collection rather than an unoptimized one.

\Drupal\Core\Language\LanguageInterface $language: (optional) The interface language the assets will be rendered with.

Return value

array A (possibly optimized) collection of CSS assets.

See also

https://www.drupal.org/node/1887918#separate-concerns

1 method overrides AssetResolverInterface::getCssAssets()
AssetResolver::getCssAssets in core/lib/Drupal/Core/Asset/AssetResolver.php
Returns the CSS assets for the current response's libraries.

File

core/lib/Drupal/Core/Asset/AssetResolverInterface.php, line 54

Class

AssetResolverInterface
Resolves asset libraries into concrete CSS and JavaScript assets.

Namespace

Drupal\Core\Asset

Code

public function getCssAssets(AttachedAssetsInterface $assets, $optimize, ?LanguageInterface $language = NULL);

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal