hook_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets)
Perform necessary alterations to the JavaScript settings (drupalSettings).
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
- Hooks
- Define functions that alter the behavior of Drupal core.
File
- core/lib/Drupal/Core/Render/theme.api.php, line 924
- Hooks and documentation related to the theme and render system.
Code
function hook_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) { // Add settings. $settings['user']['uid'] = \Drupal::currentUser(); // Manipulate settings. if (isset($settings['dialog'])) { $settings['dialog']['autoResize'] = FALSE; } }
Please login to continue.