protected function HtmlResponseAttachmentsProcessor::processAssetLibraries in Drupal 8
Same name and namespace in other branches
- 9 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 308
Class
- HtmlResponseAttachmentsProcessor
- Processes attachments of HTML responses.
Namespace
Drupal\Core\RenderCode
protected function processAssetLibraries(AttachedAssetsInterface $assets, array $placeholders) {
$variables = [];
// Print styles - if present.
if (isset($placeholders['styles'])) {
// Optimize CSS if necessary, but only during normal site operation.
$optimize_css = !defined('MAINTENANCE_MODE') && $this->config
->get('css.preprocess');
$variables['styles'] = $this->cssCollectionRenderer
->render($this->assetResolver
->getCssAssets($assets, $optimize_css));
}
// 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 = !defined('MAINTENANCE_MODE') && !\Drupal::state()
->get('system.maintenance_mode') && $this->config
->get('js.preprocess');
list($js_assets_header, $js_assets_footer) = $this->assetResolver
->getJsAssets($assets, $optimize_js);
$variables['scripts'] = $this->jsCollectionRenderer
->render($js_assets_header);
$variables['scripts_bottom'] = $this->jsCollectionRenderer
->render($js_assets_footer);
}
return $variables;
}