You are here

function settings_tray_block_view_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/settings_tray/settings_tray.module \settings_tray_block_view_alter()
  2. 9 core/modules/settings_tray/settings_tray.module \settings_tray_block_view_alter()

Implements hook_block_view_alter().

File

core/modules/settings_tray/settings_tray.module, line 77
Allows configuring blocks and other configuration from the site front-end.

Code

function settings_tray_block_view_alter(array &$build) {
  if (isset($build['#contextual_links']['block'])) {

    // Ensure that contextual links vary by whether the block has config overrides
    // or not.
    // @see _contextual_links_to_id()
    $build['#contextual_links']['block']['metadata']['has_overrides'] = _settings_tray_has_block_overrides($build['#block']) ? 1 : 0;
  }

  // Force a new 'data-contextual-id' attribute on blocks when this module is
  // enabled so as not to reuse stale data cached client-side.
  // @todo Remove when https://www.drupal.org/node/2773591 is fixed.
  $build['#contextual_links']['settings_tray'] = [
    'route_parameters' => [],
  ];
}