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

Breadcrumb

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

function AssetResolver::getJsSettingsAssets

Returns the JavaScript settings assets for this response's libraries.

Gathers all drupalSettings from all libraries in the attached assets collection and merges them.

Parameters

\Drupal\Core\Asset\AttachedAssetsInterface $assets: The assets attached to the current response.

Return value

array A (possibly optimized) collection of JavaScript assets.

1 call to AssetResolver::getJsSettingsAssets()
AssetResolver::getJsAssets in core/lib/Drupal/Core/Asset/AssetResolver.php
Returns the JavaScript assets for the current response's libraries.

File

core/lib/Drupal/Core/Asset/AssetResolver.php, line 271

Class

AssetResolver
The default asset resolver.

Namespace

Drupal\Core\Asset

Code

protected function getJsSettingsAssets(AttachedAssetsInterface $assets) {
    $settings = [];
    foreach ($this->getLibrariesToLoad($assets, 'js') as $library) {
        [
            $extension,
            $name,
        ] = explode('/', $library, 2);
        $definition = $this->libraryDiscovery
            ->getLibraryByName($extension, $name);
        if (isset($definition['drupalSettings'])) {
            $settings = NestedArray::mergeDeepArray([
                $settings,
                $definition['drupalSettings'],
            ], TRUE);
        }
    }
    return $settings;
}

API Navigation

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