function MenuUiHooks::blockViewSystemMenuBlockAlter

Same name and namespace in other branches
  1. 11.x core/modules/menu_ui/src/Hook/MenuUiHooks.php \Drupal\menu_ui\Hook\MenuUiHooks::blockViewSystemMenuBlockAlter()

Implements hook_block_view_BASE_BLOCK_ID_alter() for 'system_menu_block'.

Attributes

#[Hook('block_view_system_menu_block_alter')]

File

core/modules/menu_ui/src/Hook/MenuUiHooks.php, line 94

Class

MenuUiHooks
Hook implementations for menu_ui.

Namespace

Drupal\menu_ui\Hook

Code

public function blockViewSystemMenuBlockAlter(array &$build, BlockPluginInterface $block) : void {
  if ($block->getBaseId() == 'system_menu_block') {
    $menu_name = $block->getDerivativeId();
    $build['#contextual_links']['menu'] = [
      'route_parameters' => [
        'menu' => $menu_name,
      ],
    ];
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.