function ClaroHooks::preprocessBlock
Same name and namespace in other branches
- 11.x core/themes/claro/src/Hook/ClaroHooks.php \Drupal\claro\Hook\ClaroHooks::preprocessBlock()
Implements hook_preprocess_block() for block content.
Disables contextual links for all blocks except for layout builder blocks.
Attributes
#[Hook('preprocess_block')]
File
-
core/
themes/ claro/ src/ Hook/ ClaroHooks.php, line 189
Class
- ClaroHooks
- Hook implementations for claro.
Namespace
Drupal\claro\HookCode
public function preprocessBlock(&$variables) : void {
if (isset($variables['title_suffix']['contextual_links']) && !isset($variables['elements']['#contextual_links']['layout_builder_block'])) {
unset($variables['title_suffix']['contextual_links']);
unset($variables['elements']['#contextual_links']);
$variables['attributes']['class'] = array_diff($variables['attributes']['class'], [
'contextual-region',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.