Fluent builder for a MenuMapping, letting an app contribute or modify menu items at runtime rather than declaring them statically in controllers.xml. Obtained from the app's controller mapping list via menuController, configured with the parent menu item id, the menu type, an optional role restriction and either a controller method name or a function reference to build the actual menu items, then finished with build to register the mapping.
Group: Builders
Methods
parentId(String parentId)
Returns: MenuMappingBuilder
Sets the id of the parent menu item this mapping should attach beneath. Leave unset, or pass a blank value, for the mapping to apply under any parent.
| Parameter | Description |
|---|---|
parentId | the parent menu item's id, or blank for any parent |
type(String type)
Returns: MenuMappingBuilder
Sets which menu this mapping applies to: "website" for a website's own menu, or "admin" for the organisation admin menu. Leaving it unset is treated as "admin".
| Parameter | Description |
|---|---|
type | "website" or "admin" |
method(String method)
Returns: MenuMappingBuilder
Sets the name of the controller method to call to build the menu items when this mapping fires.
| Parameter | Description |
|---|---|
method | the name of the controller method to invoke |
role(String role)
Returns: MenuMappingBuilder
Adds a role that a user must hold, in addition to any roles already added, for this mapping to be evaluated for them. A user needs at least one of the added roles, or the Administrator role, to see it. If no role is ever added, the mapping is evaluated for every user.
| Parameter | Description |
|---|---|
role | the name of a role to require |
method(VarArgFunction method)
Returns: MenuMappingBuilder
Sets a function reference to invoke directly to build the menu items when this mapping fires, instead of naming a controller method.
| Parameter | Description |
|---|---|
method | the function reference to invoke |
build()
Returns: MenuMapping
Builds the menu mapping from the parent id, type, role and method or function reference configured on this builder, and adds it to the app's list of menu mappings.