You are here

function hook_toolbar_alter in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/toolbar/toolbar.api.php \hook_toolbar_alter()
  2. 9 core/modules/toolbar/toolbar.api.php \hook_toolbar_alter()

Alter the toolbar menu after hook_toolbar() is invoked.

This hook is invoked by Toolbar::preRenderToolbar() immediately after hook_toolbar(). The toolbar definitions are passed in by reference. Each element of the $items array is one item returned by a module from hook_toolbar(). Additional items may be added, or existing items altered.

Parameters

$items: Associative array of toolbar menu definitions returned from hook_toolbar().

Related topics

2 functions implement hook_toolbar_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

settings_tray_toolbar_alter in core/modules/settings_tray/settings_tray.module
Implements hook_toolbar_alter().
toolbar_disable_user_toolbar_toolbar_alter in core/modules/toolbar/tests/modules/toolbar_disable_user_toolbar/toolbar_disable_user_toolbar.module
Implements hook_toolbar_alter().
1 invocation of hook_toolbar_alter()
Toolbar::preRenderToolbar in core/modules/toolbar/src/Element/Toolbar.php
Builds the Toolbar as a structured array ready for rendering.

File

core/modules/toolbar/toolbar.api.php, line 163
Hooks provided by the toolbar module.

Code

function hook_toolbar_alter(&$items) {

  // Move the User tab to the right.
  $items['commerce']['#weight'] = 5;
}