You are here

private function HtmlResponseAttachmentsProcessor::getMergedAndSortedAssets in Cookie Content Blocker 8

Merges and sorts allowed and blocked assets back together.

Marks blocked assets to be able to identify them.

Parameters

array $allowed_assets: The allowed assets.

array $allowed_assets_raw: The raw allowed assets (un-optimized) used for comparison/diff.

array $blocked_assets: The blocked assets.

Return value

array The merged and sorted assets,

2 calls to HtmlResponseAttachmentsProcessor::getMergedAndSortedAssets()
HtmlResponseAttachmentsProcessor::getCssAssetCollection in src/Render/HtmlResponseAttachmentsProcessor.php
Collects the CSS assets.
HtmlResponseAttachmentsProcessor::getJsAssetCollection in src/Render/HtmlResponseAttachmentsProcessor.php
Collects the JS assets.

File

src/Render/HtmlResponseAttachmentsProcessor.php, line 257

Class

HtmlResponseAttachmentsProcessor
Processes attachments of HTML responses.

Namespace

Drupal\cookie_content_blocker\Render

Code

private function getMergedAndSortedAssets(array $allowed_assets, array $allowed_assets_raw, array $blocked_assets) : array {

  // Filter out assets that are allowed. This leaves us with only the
  // assets we want to block and (optional) additional dependent assets that
  // are not required by any other asset.
  $assets = array_merge($allowed_assets, $this
    ->markAssetsAsBlocked(array_diff_key($blocked_assets, $allowed_assets_raw)));
  uasort($assets, [
    AssetResolver::class,
    'sort',
  ]);
  return $assets;
}