Skip to content

Commit 92d82a8

Browse files
Add HOOK_wienimal_editor_toolbar_manipulators_alter
Allow other modules to manipulate the toolbar menu
1 parent f7e79ed commit 92d82a8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.1.6] - 2023-07-10
8+
### Added
9+
- Add `HOOK_wienimal_editor_toolbar_manipulators_alter` hook ([#23](https://github.com/wieni/wienimal_editor_toolbar/pull/23))
10+
711
## [4.1.5] - 2023-07-10
812
### Fixed
913
- **BC** Use AND conjunction in Route Alter ([#22](https://github.com/wieni/wienimal_editor_toolbar/pull/22))

src/Service/EditorToolbarMenuBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public function buildMenu(): array
9595
$manipulators[] = ['callable' => 'toolbar_tools_menu_navigation_links'];
9696
}
9797

98+
$this->moduleHandler->alter('wienimal_editor_toolbar_manipulators', $manipulators, $menuName);
99+
98100
$tree = $this->menuTree->transform($tree, $manipulators);
99101

100102
// Finally, build a renderable array from the transformed tree.

wienimal_editor_toolbar.api.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* Alter the menu tree manipulators used by the editor toolbar.
5+
*
6+
* @see \Drupal\wienimal_editor_toolbar\Service\EditorToolbarMenuBuilder::buildMenu()
7+
* @param array $manipulators
8+
* @param string $menuName
9+
*/
10+
function hook_wienimal_editor_toolbar_manipulators_alter(array &$manipulators, string $menuName): void
11+
{
12+
$manipulators[] = [
13+
'callable' => 'my_module.my_service:hideMenuItems',
14+
];
15+
}

0 commit comments

Comments
 (0)