function HtmlResponseAttachmentsProcessor::processAssetLibraries
Same name in other branches
- 9 core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processAssetLibraries()
- 8.9.x core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processAssetLibraries()
- 11.x core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php \Drupal\Core\Render\HtmlResponseAttachmentsProcessor::processAssetLibraries()
Processes asset libraries into render arrays.
Parameters
\Drupal\Core\Asset\AttachedAssetsInterface $assets: The attached assets collection for the current response.
array $placeholders: The placeholders that exist in the response.
Return value
array An array keyed by asset type, with keys:
- styles
- scripts
- scripts_bottom
1 call to HtmlResponseAttachmentsProcessor::processAssetLibraries()
- HtmlResponseAttachmentsProcessor::processAttachments in core/
lib/ Drupal/ Core/ Render/ HtmlResponseAttachmentsProcessor.php - Processes the attachments of a response that has attachments.
File
-
core/
lib/ Drupal/ Core/ Render/ HtmlResponseAttachmentsProcessor.php, line 314
Class
- HtmlResponseAttachmentsProcessor
- Processes attachments of HTML responses.
Namespace
Drupal\Core\RenderCode
protected function processAssetLibraries(AttachedAssetsInterface $assets, array $placeholders) {
$variables = [];
$maintenance_mode = defined('MAINTENANCE_MODE') || \Drupal::state()->get('system.maintenance_mode');
// Print styles - if present.
if (isset($placeholders['styles'])) {
// Optimize CSS if necessary, but only during normal site operation.
$optimize_css = !$maintenance_mode && $this->config
->get('css.preprocess');
$variables['styles'] = $this->cssCollectionRenderer
->render($this->assetResolver
->getCssAssets($assets, $optimize_css, $this->languageManager
->getCurrentLanguage()));
}
// Print scripts - if any are present.
if (isset($placeholders['scripts']) || isset($placeholders['scripts_bottom'])) {
// Optimize JS if necessary, but only during normal site operation.
$optimize_js = !$maintenance_mode && $this->config
->get('js.preprocess');
[
$js_assets_header,
$js_assets_footer,
] = $this->assetResolver
->getJsAssets($assets, $optimize_js, $this->languageManager
->getCurrentLanguage());
$variables['scripts'] = $this->jsCollectionRenderer
->render($js_assets_header);
$variables['scripts_bottom'] = $this->jsCollectionRenderer
->render($js_assets_footer);
}
return $variables;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.