You are here

private function HtmlResponseAttachmentsProcessor::renderAssetCollection in Cookie Content Blocker 8

Renders asset collections and inserts placeholders for blocked assets.

Parameters

array $collection: The asset collection to render.

\Drupal\Core\Asset\AssetCollectionRendererInterface $renderer: The renderer to use to render the collection.

Return value

array The render array for the asset collection.

4 calls to HtmlResponseAttachmentsProcessor::renderAssetCollection()
HtmlResponseAttachmentsProcessor::processAssetLibraries in src/Render/HtmlResponseAttachmentsProcessor.php
Processes asset libraries into render arrays.
HtmlResponseAttachmentsProcessor::processScripts in src/Render/HtmlResponseAttachmentsProcessor.php
Processes js assets and creates output for the 'scripts' variable.
HtmlResponseAttachmentsProcessor::processScriptsBottom in src/Render/HtmlResponseAttachmentsProcessor.php
Processes js assets and creates output for the 'scripts_bottom' variable.
HtmlResponseAttachmentsProcessor::processStyles in src/Render/HtmlResponseAttachmentsProcessor.php
Processes css assets and creates output for the 'styles' variable.

File

src/Render/HtmlResponseAttachmentsProcessor.php, line 332

Class

HtmlResponseAttachmentsProcessor
Processes attachments of HTML responses.

Namespace

Drupal\cookie_content_blocker\Render

Code

private function renderAssetCollection(array $collection, AssetCollectionRendererInterface $renderer) : array {
  $rendered = [
    [],
  ];
  foreach ($collection as $asset) {
    $rendered_asset = $renderer
      ->render([
      $asset,
    ]);
    $rendered[] = !empty($asset['is_blocked']) ? [
      $this
        ->generateAssetPlaceholder(...$rendered_asset),
    ] : $rendered_asset;
  }
  return array_merge(...$rendered);
}