Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. JsAssetController.php

function JsAssetController::getGroups

Overrides AssetControllerBase::getGroups

File

core/modules/system/src/Controller/JsAssetController.php, line 47

Class

JsAssetController
Defines a controller to serve Javascript aggregates.

Namespace

Drupal\system\Controller

Code

protected function getGroups(AttachedAssetsInterface $attached_assets, Request $request) : array {
    // The header and footer scripts are two distinct sets of asset groups. The
    // $group_key is not sufficient to find the group, we also need to locate it
    // within either the header or footer set.
    $language = $this->languageManager()
        ->getLanguage($request->get('language'));
    [
        $js_assets_header,
        $js_assets_footer,
    ] = $this->assetResolver
        ->getJsAssets($attached_assets, FALSE, $language);
    $scope = $request->get('scope');
    if (!isset($scope)) {
        throw new BadRequestHttpException('The URL must have a scope query argument.');
    }
    $assets = $scope === 'header' ? $js_assets_header : $js_assets_footer;
    // While the asset resolver will find settings, these are never aggregated,
    // so filter them out.
    unset($assets['drupalSettings']);
    return $this->grouper
        ->group($assets);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal