function hook_js_settings_build

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Render/theme.api.php \hook_js_settings_build()
  2. 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_js_settings_build()
  3. 11.x 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

2 functions implement hook_js_settings_build()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

SystemHooks::jsSettingsBuild in core/modules/system/src/Hook/SystemHooks.php
Implements hook_js_settings_build().
system_js_settings_build in core/modules/system/system.module
Implements hook_js_settings_build().

File

core/lib/Drupal/Core/Render/theme.api.php, line 977

Code

function hook_js_settings_build(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
  // Manipulate settings.
  if (isset($settings['dialog'])) {
    $settings['dialog']['autoResize'] = FALSE;
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.