MenuGroups
in package
Uses
MenuSortTrait
Class MenuGroups
Table of Contents
- $items : array<string|int, MenuGroup>
- add() : void
- Adds a menu group.
- filter() : void
- Filters menu group items.
- isEmpty() : bool
- reset() : void
- Resets the internal collection data.
- sort() : void
- Sort collected menu groups and their items.
- toArray() : array<string|int, mixed>
- Array serialization.
- has() : bool
- Checks if any menu group with same id is already collected.
- recursiveArrayUnique() : array<string|int, mixed>
- Recursively filter the given array and returns a result with unique items only.
- sortCallback() : callable
- tryMerge() : bool
- Merges the given menu group if another group with the same id is already collected.
Properties
$items
private
array<string|int, MenuGroup>
$items
= []
Methods
add()
Adds a menu group.
public
add(MenuGroup $menuGroup) : void
Parameters
- $menuGroup : MenuGroup
Return values
void —filter()
Filters menu group items.
public
filter(FilterFactory $filterFactory) : void
This function filter menu group items by using conditions, if available and performing a check if the menu group should be used in the final structure, or is restricted by some configurations.
Parameters
- $filterFactory : FilterFactory
Return values
void —isEmpty()
public
isEmpty() : bool
Return values
bool —reset()
Resets the internal collection data.
public
reset() : void
Return values
void —sort()
Sort collected menu groups and their items.
public
sort() : void
Return values
void —toArray()
Array serialization.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed> —has()
Checks if any menu group with same id is already collected.
private
has(MenuGroup $group) : bool
Parameters
- $group : MenuGroup
Return values
bool —recursiveArrayUnique()
Recursively filter the given array and returns a result with unique items only.
private
recursiveArrayUnique(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed> —sortCallback()
private
sortCallback() : callable
Return values
callable —tryMerge()
Merges the given menu group if another group with the same id is already collected.
private
tryMerge(MenuGroup $group) : bool
Returns true if the group was merged and false otherwise.
Parameters
- $group : MenuGroup