class MenuHandler

Class MenuHandler

Traits

Constants

DUPLICATE_RETRY_CNT

Limit count of retry for ID duplicated

ACCESS

Access action keyword for permission

VISIBLE

Visible action keyword for permission

Properties

protected MenuRepository $menus MenuRepository instance
protected MenuItemRepository $items MenuItemRepository instance
protected ConfigManager $configs ConfigManager instance
protected ModuleHandler $modules ModuleHandler instance
protected RouteRepository $routes RouteRepository instance
protected string $menuKeyword Menu keyword for config

Methods

bool
linkHierarchy(Node $item, Node $parent)

Linked parent and child relation

int
unlinkHierarchy(Node $item, Node $parent)

unlinked parent and child relation

void
setOrder(Node $item, int|null $position = null)

Set item ordering value

__construct(MenuRepository $menus, MenuItemRepository $items, ConfigManager $configs, ModuleHandler $modules, RouteRepository $routes)

MenuHandler constructor.

get(string $id, array $with = array())

Get menu

Menu[]
getAll(string $siteKey, array $with = array())

Get all menu

create(array $attributes)

Create new menu

createMenu(array $attributes)

Create new menu

put(Menu $menu, array $attributes = array())

Update category

updateMenu(Menu $menu, array $attributes = array())

Update category

bool
remove(Menu $menu)

Delete menu

bool
deleteMenu(Menu $menu)

Delete menu

getItem(string $id, array $with = array())

Get menu item

getItemIn(array $ids, array $with = array())

Get menu item list by identifiers

createItem(Menu $menu, array $attributes, array $menuTypeInput = array())

Create new menu item

void
setHierarchy(MenuItem $item)

Set hierarchy information for new item

void
storeMenuType(MenuItem $item, array $menuTypeInput)

Store menu type associated with the menu item.

putItem(MenuItem $item, array $menuTypeInput = array())

Update menu item

updateItem(MenuItem $item, array $attributes, array $menuTypeInput = array())

Update menu item

void
updateMenuType(MenuItem $item, array $menuTypeInput)

Update menu type associated with the menu item.

bool|null
removeItem(MenuItem $item)

Delete menu item

bool|null
deleteItem(MenuItem $item)

Delete menu item

void
deleteMenuType(MenuItem $item)

Delete menu type associated with the menu item.

moveItem(Menu $menu, MenuItem $item, MenuItem $parent = null)

Move menu item

void
setMenuTheme(Menu $menu, string $desktopTheme, string $mobileTheme)

Set menu config consisting of theme identifiers

getMenuTheme(Menu $menu)

Get menu config consisting of theme identifiers

void
updateMenuTheme(Menu $menu, string $desktopTheme, string $mobileTheme)

Update menu config consisting of theme identifiers

void
deleteMenuTheme(Menu $menu)

Delete menu config consisting of theme identifiers

void
setMenuItemTheme(MenuItem $item, string $desktopTheme, string $mobileTheme)

Set menu config consisting of theme identifiers

getMenuItemTheme(MenuItem $item)

Get menu item config consisting of theme identifiers

void
updateMenuItemTheme(MenuItem $item, string $desktopTheme, string $mobileTheme)

Update menu item config consisting of theme identifiers

void
deleteMenuItemTheme(MenuItem $item)

Delete menu item config consisting of theme identifiers

void
moveItemConfig(MenuItem $beforeItem, MenuItem $movedItem)

Move menu item config consisting of theme identifiers

string
menuKeyString(MenuItem|string $value)

Make key string for config

getDefaultGrant()

Get default grant

string
permKeyString(MenuItem $item)

Make key string for permission

string|null
getInstanceSettingURI(MenuItem $item)

Get setting page url by menu item

string|null
getInstanceSettingURIByItemId(string $itemId)

Get setting page url by menu item id

getModuleHandler()

Get ModuleHandler instance

menus()

Get MenuRepository instance

items()

Get MenuItemRepository instance

Details

in NodePositionTrait at line 36
protected bool linkHierarchy(Node $item, Node $parent)

Linked parent and child relation

Parameters

Node $item child item instance
Node $parent parent item instance

Return Value

bool

in NodePositionTrait at line 69
protected int unlinkHierarchy(Node $item, Node $parent)

unlinked parent and child relation

Parameters

Node $item child item instance
Node $parent parent item instance

Return Value

int affected row count

in NodePositionTrait at line 95
void setOrder(Node $item, int|null $position = null)

Set item ordering value

Parameters

Node $item item object
int|null $position sequence value

Return Value

void

at line 115
__construct(MenuRepository $menus, MenuItemRepository $items, ConfigManager $configs, ModuleHandler $modules, RouteRepository $routes)

MenuHandler constructor.

Parameters

MenuRepository $menus MenuRepository instance
MenuItemRepository $items MenuItemRepository instance
ConfigManager $configs ConfigManager instance
ModuleHandler $modules ModuleHandler instance
RouteRepository $routes RouteRepository instance

at line 138
Menu get(string $id, array $with = array())

Get menu

Parameters

string $id menu identifier
array $with relation

Return Value

Menu

at line 152
Menu[] getAll(string $siteKey, array $with = array())

Get all menu

Parameters

string $siteKey site key
array $with relation

Return Value

Menu[]

at line 165
Menu create(array $attributes)

Create new menu

Parameters

array $attributes attributes

Return Value

Menu

at line 176
Menu createMenu(array $attributes)

Create new menu

Parameters

array $attributes attributes

Return Value

Menu

at line 190
Menu put(Menu $menu, array $attributes = array())

Update category

Parameters

Menu $menu menu instance
array $attributes attributes

Return Value

Menu

at line 202
Menu updateMenu(Menu $menu, array $attributes = array())

Update category

Parameters

Menu $menu menu instance
array $attributes attributes

Return Value

Menu

at line 216
bool remove(Menu $menu)

Delete menu

Parameters

Menu $menu menu instance

Return Value

bool

Exceptions

CanNotDeleteMenuEntityHaveChildException

at line 228
bool deleteMenu(Menu $menu)

Delete menu

Parameters

Menu $menu menu instance

Return Value

bool

Exceptions

CanNotDeleteMenuEntityHaveChildException

at line 248
MenuItem getItem(string $id, array $with = array())

Get menu item

Parameters

string $id menu item identifier
array $with relation

Return Value

MenuItem

at line 262
MenuItem[] getItemIn(array $ids, array $with = array())

Get menu item list by identifiers

Parameters

array $ids menu item identifier list
array $with relation

Return Value

MenuItem[]

at line 275
MenuItem createItem(Menu $menu, array $attributes, array $menuTypeInput = array())

Create new menu item

Parameters

Menu $menu menu instance
array $attributes item's attributes
array $menuTypeInput input for menu type module

Return Value

MenuItem

at line 295
protected void setHierarchy(MenuItem $item)

Set hierarchy information for new item

Parameters

MenuItem $item item object

Return Value

void

at line 311
protected void storeMenuType(MenuItem $item, array $menuTypeInput)

Store menu type associated with the menu item.

Parameters

MenuItem $item menu item instance
array $menuTypeInput input for menu type module

Return Value

void

at line 337
MenuItem putItem(MenuItem $item, array $menuTypeInput = array())

Update menu item

Parameters

MenuItem $item item instance
array $menuTypeInput input for menu type module

Return Value

MenuItem

at line 350
MenuItem updateItem(MenuItem $item, array $attributes, array $menuTypeInput = array())

Update menu item

Parameters

MenuItem $item item instance
array $attributes attributes
array $menuTypeInput input for menu type module

Return Value

MenuItem

at line 373
protected void updateMenuType(MenuItem $item, array $menuTypeInput)

Update menu type associated with the menu item.

Parameters

MenuItem $item menu item instance
array $menuTypeInput input for menu type module

Return Value

void

at line 395
bool|null removeItem(MenuItem $item)

Delete menu item

Parameters

MenuItem $item item instance

Return Value

bool|null

Exceptions

CanNotDeleteMenuItemHaveChildException

at line 407
bool|null deleteItem(MenuItem $item)

Delete menu item

Parameters

MenuItem $item item instance

Return Value

bool|null

Exceptions

CanNotDeleteMenuItemHaveChildException

at line 424
protected void deleteMenuType(MenuItem $item)

Delete menu type associated with the menu item.

Parameters

MenuItem $item menu item instance

Return Value

void

at line 444
MenuItem moveItem(Menu $menu, MenuItem $item, MenuItem $parent = null)

Move menu item

Parameters

Menu $menu menu instance
MenuItem $item menu item instance
MenuItem $parent menu item instance

Return Value

MenuItem

Exceptions

InvalidArgumentException

at line 478
void setMenuTheme(Menu $menu, string $desktopTheme, string $mobileTheme)

Set menu config consisting of theme identifiers

Parameters

Menu $menu menu instance
string $desktopTheme theme id
string $mobileTheme theme id

Return Value

void

at line 495
ConfigEntity getMenuTheme(Menu $menu)

Get menu config consisting of theme identifiers

Parameters

Menu $menu menu instance

Return Value

ConfigEntity

at line 508
void updateMenuTheme(Menu $menu, string $desktopTheme, string $mobileTheme)

Update menu config consisting of theme identifiers

Parameters

Menu $menu menu instance
string $desktopTheme theme id
string $mobileTheme theme id

Return Value

void

at line 525
void deleteMenuTheme(Menu $menu)

Delete menu config consisting of theme identifiers

Parameters

Menu $menu menu instance

Return Value

void

at line 538
void setMenuItemTheme(MenuItem $item, string $desktopTheme, string $mobileTheme)

Set menu config consisting of theme identifiers

Parameters

MenuItem $item menu item instance
string $desktopTheme theme id
string $mobileTheme theme id

Return Value

void

at line 555
ConfigEntity getMenuItemTheme(MenuItem $item)

Get menu item config consisting of theme identifiers

Parameters

MenuItem $item menu item instance

Return Value

ConfigEntity

at line 570
void updateMenuItemTheme(MenuItem $item, string $desktopTheme, string $mobileTheme)

Update menu item config consisting of theme identifiers

Parameters

MenuItem $item menu item instance
string $desktopTheme theme id
string $mobileTheme theme id

Return Value

void

at line 587
void deleteMenuItemTheme(MenuItem $item)

Delete menu item config consisting of theme identifiers

Parameters

MenuItem $item menu item instance

Return Value

void

at line 599
void moveItemConfig(MenuItem $beforeItem, MenuItem $movedItem)

Move menu item config consisting of theme identifiers

Parameters

MenuItem $beforeItem before item
MenuItem $movedItem after item

Return Value

void

at line 613
protected string menuKeyString(MenuItem|string $value)

Make key string for config

Parameters

MenuItem|string $value to generate for config key string

Return Value

string

at line 630
Grant getDefaultGrant()

Get default grant

Return Value

Grant

at line 653
string permKeyString(MenuItem $item)

Make key string for permission

Parameters

MenuItem $item menu item instance

Return Value

string

at line 666
string|null getInstanceSettingURI(MenuItem $item)

Get setting page url by menu item

Parameters

MenuItem $item menu item instance

Return Value

string|null

at line 679
string|null getInstanceSettingURIByItemId(string $itemId)

Get setting page url by menu item id

Parameters

string $itemId menu item identifier

Return Value

string|null

at line 693
ModuleHandler getModuleHandler()

Get ModuleHandler instance

Return Value

ModuleHandler

at line 703
MenuRepository menus()

Get MenuRepository instance

Return Value

MenuRepository

at line 713
MenuItemRepository items()

Get MenuItemRepository instance

Return Value

MenuItemRepository