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

Breadcrumb

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

function SettingsTrayHooks::blockViewAlter

Implements hook_block_view_alter().

File

core/modules/settings_tray/src/Hook/SettingsTrayHooks.php, line 74

Class

SettingsTrayHooks
Hook implementations for settings_tray.

Namespace

Drupal\settings_tray\Hook

Code

public function blockViewAlter(array &$build) : void {
    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' => [],
    ];
}

API Navigation

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