- Issue created by @clgarciab
- 🇦🇺Australia nterbogt
This ticket is best placed on the admin_toolbar module rather than core.
That said, you can't currently override a deriver as far as I'm aware. The code to do that doesn't exist, see ✨ Allow base plugin definition to be altered before derived Active .
You can however override the menu links by using a module hook. Here is an example from our codebase.
/** * Implements hook_menu_links_discovered_alter(). */ function MY_MODULE_menu_links_discovered_alter(&$links) { foreach ($links as $route_name => $link) { // Remove all the individual views from the menu. if (\str_starts_with($route_name, 'admin_toolbar_tools.extra_links:views_ui') && !\in_array($route_name, ['admin_toolbar_tools.extra_links:views_ui.add', 'admin_toolbar_tools.extra_links:views_ui.field_list'])) { unset($links[$route_name]); } } }
- 🇫🇷France dydave
Thanks a lot @nterbogt for the very clear and great answer, it is very helpful! 🙏
Allow other modules to alter/modify the menu links added by
admin_toolbar
(or any of its sub-modules).This seems to be a rather frequent/recurring request and requirement, so we should probably create a specific documentation page to explain and describe the approach suggested at #2.
Information about other potential methods of extension of the Extralinks class and why it was made final could also be explained in the same documentation, with a specific section, see for example:- Documentation on how to Extend Smart Trim → contrib module.
- #3514075-8: unsafe usage of new static() →
- 📌 GitLab CI - PHPStan - "Unsafe usage of new static()" Fixed
Ideally, a paragraph should also be added on project's page to direct users to this ticket and the documentation page:
"Extending Admin Toolbar" > "Overriding menu links added by Admin Toolbar Tools"
The same changes would probably also need to be added to module's README.md file or in sub-moduleadmin_toolbar_tools
Re-qualifying ticket as an active Task which should hopefully result in the creation of a new documentation page for the module.
Feel free to let us know if you have any suggestions, comments or questions on this particular comment, or the issue in general, we would surely be glad to help.
Thanks in advance! 🙂