Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntimeX committed May 3, 2024
1 parent 5e440cd commit b914686
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/package/acp-menu-items.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ACP Menu Items

The API for the ACP menu items allows you to add your own menu items in the admin panel with your package.
The API for the ACP menu items allows you to add your own menu items in the admin panel for your package.

Since WoltLab Suite 6.1 you can attach an event listener to the `wcf\system\menu\acp\event\AcpMenuCollecting` event inside a bootstrap script to lazily register your ACP menu items.

Expand All @@ -12,7 +12,7 @@ The `register` method of the event expects an object of the type `wcf\system\men
| `$title` | string | (Optional) title of the item; if omitted `$menuItem` is used as language variable |
| `$parentMenuItem` | string | (Optional) identifier of the parent item |
| `$link` | string | (Optional) URL of the linked page |
| `$icon` | string | (Optional) icon of the item |
| `$icon` | ?FontAwesomeIcon | (Optional) icon of the item |

Example:

Expand All @@ -23,6 +23,7 @@ use wcf\system\event\EventHandler;
use wcf\system\menu\acp\AcpMenuItem;
use wcf\system\menu\acp\event\AcpMenuCollecting;
use wcf\system\request\LinkHandler;
use wcf\system\style\FontAwesomeIcon;

return static function (): void {
EventHandler::getInstance()->register(AcpMenuCollecting::class, static function (AcpMenuCollecting $event) {
Expand All @@ -32,13 +33,13 @@ return static function (): void {
'wcf.acp.menu.link.application'
));

if (true) {
if ($currentUserHasSomeSpecificPermission) {
$event->register(new AcpMenuItem(
"com.woltlab.foor.bar.add",
'Example Add Title',
"com.woltlab.foor.bar",
LinkHandler::getInstance()->getControllerLink(FooAddForm::class),
'plus;false'
FontAwesomeIcon::fromString('plus;false')
));
}
});
Expand Down

0 comments on commit b914686

Please sign in to comment.