AssetResolverInterface
interface AssetResolverInterface (View source)
Resolves asset libraries into concrete CSS and JavaScript assets.
Given an attached assets collection (to be loaded for the current response), the asset resolver can resolve those asset libraries into a list of concrete CSS and JavaScript assets.
In other words: this allows developers to translate Drupal's asset abstraction (asset libraries) into concrete assets.
Methods
Returns the CSS assets for the current response's libraries.
Returns the JavaScript assets for the current response's libraries.
Details
array
getCssAssets(AttachedAssetsInterface $assets, bool $optimize)
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
array
getJsAssets(AttachedAssetsInterface $assets, bool $optimize)
Returns the JavaScript assets for the current response's libraries.
References to JavaScript files are placed in a certain order: first, all 'core' files, then all 'module' and finally all 'theme' JavaScript files are added to the page. Then, all settings are output, followed by 'inline' JavaScript code. If running update.php, all preprocessing is disabled.
Note that hook_js_alter(&$javascript) is called during this function call to allow alterations of the JavaScript during its presentation. The correct way to add JavaScript during hook_js_alter() is to add another element to the $javascript array, deriving from drupal_js_defaults(). See locale_js_alter() for an example of this.