MenuItems
in package
Menu items class.
Works about menu (including permission check).
Tags
Table of Contents
Properties
- $Container : Container
Methods
- __construct() : mixed
- Class constructor.
- getMenuItems() : array<string|int, mixed>
- Get menu items from all modules and do permission check to list only allowed.
- addToMenu() : array<string|int, mixed>
- Add additional menu items to core menu.
- convertMenuArrayKeyToFloat() : array<string|int, mixed>
- Convert menu items array key to float (string) value.
- filterMenuPermissions() : array<string|int, mixed>
- Filter to list only allowed by permissions.
- increaseArrayKeyDec() : mixed
- Increase array key decimal part that is not duplicate with existing menu items.
Properties
$Container
protected
Container
$Container
Methods
__construct()
Class constructor.
public
__construct(Container $Container) : mixed
Parameters
- $Container : Container
-
The DI container class.
getMenuItems()
Get menu items from all modules and do permission check to list only allowed.
public
getMenuItems([array<string|int, mixed> $cookieData = [] ]) : array<string|int, mixed>
This method was called from XhrCommonDataController->getUrlsMenuItems()
controller.
Parameters
- $cookieData : array<string|int, mixed> = []
-
The cookie data. This will be safe time to decrypt cookie by use it from
Admin\Users\Sessions\Traits\SessionsTrait
.
Return values
array<string|int, mixed> —Return array list of menu items.
addToMenu()
Add additional menu items to core menu.
protected
addToMenu(array<string|int, mixed> $menuItems, array<string|int, mixed> $additionalMenuItems) : array<string|int, mixed>
This method was called from getMenuItems()
.
Parameters
- $menuItems : array<string|int, mixed>
-
The menu items. This menu items should be converted array key via
convertMenuArrayKeyToFloat()
method before. - $additionalMenuItems : array<string|int, mixed>
-
The additional menu items. This menu items should be converted array key via
convertMenuArrayKeyToFloat()
method before.
Return values
array<string|int, mixed> —Return modified menu items that additional menu items was added into it.
convertMenuArrayKeyToFloat()
Convert menu items array key to float (string) value.
protected
convertMenuArrayKeyToFloat(array<string|int, mixed> $menuItems) : array<string|int, mixed>
Also convert sub menu items.
This method was called from getMenuItems()
.
Parameters
- $menuItems : array<string|int, mixed>
-
The menu items.
Return values
array<string|int, mixed> —Return converted array keys.
filterMenuPermissions()
Filter to list only allowed by permissions.
protected
filterMenuPermissions(string $moduleSystemName, array<string|int, mixed> $menuItems) : array<string|int, mixed>
This method was called from getMenuItems()
.
Parameters
- $moduleSystemName : string
-
The module system name of this menu items.
- $menuItems : array<string|int, mixed>
-
The menu items as seen in the [module_system_name]/ModuleData/ModuleAdmin.php or read more at \Rdb\Modules\RdbAdmin\Interfaces\ModuleAdmin interface
Return values
array<string|int, mixed> —Return the same array structure but filtered to list only permission granted.
increaseArrayKeyDec()
Increase array key decimal part that is not duplicate with existing menu items.
protected
increaseArrayKeyDec(float|string $number, array<string|int, mixed> $menuItems) : mixed
This method was called from addToMenu()
.
Parameters
- $number : float|string
-
The array key number. This number should be converted from int to float (number with dot).
- $menuItems : array<string|int, mixed>
-
The menu item.