diff --git a/docs/migration/wsc60/php.md b/docs/migration/wsc60/php.md index b92a11d9..5ff7e42d 100644 --- a/docs/migration/wsc60/php.md +++ b/docs/migration/wsc60/php.md @@ -32,3 +32,7 @@ class MyForm extends AbstractForm { ## RSS Feeds A [new API](../../php/api/rss_feeds.md) for the output of content as an RSS feed has been introduced. + +## ACP Menu Items + +A [new API](../../package/acp-menu-items.md) for adding ACP menu items has been introduced. The previous option of adding menu entries via PIP is still supported, but is to be discontinued in the long term. diff --git a/docs/package/acp-menu-items.md b/docs/package/acp-menu-items.md new file mode 100644 index 00000000..8fed856b --- /dev/null +++ b/docs/package/acp-menu-items.md @@ -0,0 +1,47 @@ +# ACP Menu Items + +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. + +The `register` method of the event expects an object of the type `wcf\system\menu\acp\AcpMenuItem` as a parameter. An `AcpMenuItem` object consists of the following parameters: + +| Name | Type | Description | +|------|------|-------------| +| `$menuItem` | string | Identifier of the item; must be unique | +| `$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` | ?FontAwesomeIcon | (Optional) icon of the item | + +Example: + +```php +register(AcpMenuCollecting::class, static function (AcpMenuCollecting $event) { + $event->register(new AcpMenuItem( + "com.woltlab.foor.bar", + 'Example Title', + 'wcf.acp.menu.link.application' + )); + + if ($currentUserHasSomeSpecificPermission) { + $event->register(new AcpMenuItem( + "com.woltlab.foor.bar.add", + 'Example Add Title', + "com.woltlab.foor.bar", + LinkHandler::getInstance()->getControllerLink(FooAddForm::class), + FontAwesomeIcon::fromString('plus;false') + )); + } + }); +}; +``` diff --git a/mkdocs.yml b/mkdocs.yml index e4f50a58..b8b5d767 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -113,6 +113,7 @@ nav: - 'userNotificationEvent': 'package/pip/user-notification-event.md' - 'userOption': 'package/pip/user-option.md' - 'userProfileMenu': 'package/pip/user-profile-menu.md' + - 'ACP Menu Items': 'package/acp-menu-items.md' - 'Database PHP API': 'package/database-php-api.md' - 'Migration':