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\HookCode
public function blockViewAlter(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' => [],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.