You are here

function hook_js_settings_build in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Render/theme.api.php \hook_js_settings_build()
  2. 10 core/lib/Drupal/Core/Render/theme.api.php \hook_js_settings_build()

Modify the JavaScript settings (drupalSettings).

The results of this hook are cached, however modules may use hook_js_settings_alter() to dynamically alter settings.

Parameters

array &$settings: An array of all JavaScript settings (drupalSettings) being presented on the page.

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

See also

\Drupal\Core\Asset\AssetResolver

Related topics

1 function implements hook_js_settings_build()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

system_js_settings_build in core/modules/system/system.module
Implements hook_js_settings_build().
1 invocation of hook_js_settings_build()
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/Render/theme.api.php, line 944
Hooks and documentation related to the theme and render system.

Code

function hook_js_settings_build(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {

  // Manipulate settings.
  if (isset($settings['dialog'])) {
    $settings['dialog']['autoResize'] = FALSE;
  }
}