Elgg  Version master
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Menu\Service Class Reference

Methods to construct and prepare menus for rendering. More...

Public Member Functions

 __construct (protected EventsService $events, protected Config $config)
 Constructor. More...
 
 getMenu (string $name, array $params=[])
 Build a full menu, pulling items from configuration and the "register" menu events. More...
 
 getUnpreparedMenu (string $name, array $params=[])
 Build an unprepared menu. More...
 
 prepareMenu (UnpreparedMenu $menu)
 Split a menu into sections, and pass it through the "prepare" event. More...
 
 combineMenus (array $names=[], array $params=[], string $new_name= '')
 Combine several menus into one. More...
 
 prepareMenuItems (array $items=[])
 Prepare menu items. More...
 
 registerMenuItem (string $menu_name,\ElggMenuItem $menu_item)
 Register a menu item. More...
 
 unregisterMenuItem (string $menu_name, string $item_name)
 Remove an item from a menu. More...
 
 getAllMenus ()
 Returns all registered menu items. More...
 

Protected Member Functions

 prepareVerticalMenu (PreparedMenu $menu, array $params)
 Prepares a vertical menu by setting the display child menu option to "toggle" if not set. More...
 
 prepareSelectedParents (PreparedMenu $menu, array $params)
 Marks parents of selected items also as selected. More...
 
 prepareDropdownMenu (PreparedMenu $menu, array $params)
 Prepares a dropdown menu. More...
 
 prepareItemContentsView (PreparedMenu $menu, array $params)
 Set a content view for each menu item based on the default for the menu. More...
 

Protected Attributes

 $menus = []
 

Detailed Description

Methods to construct and prepare menus for rendering.

Definition at line 11 of file Service.php.

Constructor & Destructor Documentation

Elgg\Menu\Service::__construct ( protected EventsService  $events,
protected Config  $config 
)

Constructor.

Parameters
EventsService$eventsEvents
Config$configElgg config

Definition at line 24 of file Service.php.

Member Function Documentation

Elgg\Menu\Service::combineMenus ( array  $names = [],
array  $params = [],
string  $new_name = '' 
)

Combine several menus into one.

Unprepared menus will be built separately, then combined, with items reassigned to sections named after their origin menu. The returned menu must be prepared before display.

Parameters
string[]$names Menu names
array$paramsMenu params
string$new_nameCombined menu name (used for the prepare event)
Returns

Definition at line 282 of file Service.php.

Elgg\Menu\Service::getAllMenus ( )

Returns all registered menu items.

Used for debugging purpose.

Returns
[]
Since
5.0

Definition at line 381 of file Service.php.

Elgg\Menu\Service::getMenu ( string  $name,
array  $params = [] 
)

Build a full menu, pulling items from configuration and the "register" menu events.

Parameters are filtered by the "parameters" event.

Parameters
string$nameMenu name
array$paramsEvent/view parameters
Returns

Definition at line 37 of file Service.php.

Elgg\Menu\Service::getUnpreparedMenu ( string  $name,
array  $params = [] 
)

Build an unprepared menu.

Parameters
string$nameMenu name
array$paramsEvent/view parameters
Returns

Definition at line 49 of file Service.php.

Elgg\Menu\Service::prepareDropdownMenu ( PreparedMenu  $menu,
array  $params 
)
protected

Prepares a dropdown menu.

Parameters
PreparedMenu$menuthe current prepared menu
array$paramsthe menu params
Returns

Definition at line 203 of file Service.php.

Elgg\Menu\Service::prepareItemContentsView ( PreparedMenu  $menu,
array  $params 
)
protected

Set a content view for each menu item based on the default for the menu.

Parameters
PreparedMenu$menuthe current prepared menu
array$paramsthe menu params
Returns
Since
4.2

Definition at line 246 of file Service.php.

Elgg\Menu\Service::prepareMenu ( UnpreparedMenu  $menu)

Split a menu into sections, and pass it through the "prepare" event.

Parameters
UnpreparedMenu$menuMenu
Returns

Definition at line 95 of file Service.php.

Elgg\Menu\Service::prepareMenuItems ( array  $items = [])

Prepare menu items.

Parameters
array$itemsAn array of instances or menu item factory options
Returns

Definition at line 317 of file Service.php.

Elgg\Menu\Service::prepareSelectedParents ( PreparedMenu  $menu,
array  $params 
)
protected

Marks parents of selected items also as selected.

Parameters
PreparedMenu$menuthe current prepared menu
array$paramsthe menu params
Returns

Definition at line 179 of file Service.php.

Elgg\Menu\Service::prepareVerticalMenu ( PreparedMenu  $menu,
array  $params 
)
protected

Prepares a vertical menu by setting the display child menu option to "toggle" if not set.

Parameters
PreparedMenu$menuthe current prepared menu
array$paramsthe menu params
Returns

Definition at line 142 of file Service.php.

Elgg\Menu\Service::registerMenuItem ( string  $menu_name,
\ElggMenuItem  $menu_item 
)

Register a menu item.

Parameters
string$menu_nameThe name of the menu
mixed$menu_itemAn object
Returns
void
Since
5.0

Definition at line 345 of file Service.php.

Elgg\Menu\Service::unregisterMenuItem ( string  $menu_name,
string  $item_name 
)

Remove an item from a menu.

Parameters
string$menu_nameThe name of the menu
string$item_nameThe unique identifier for this menu item
Returns
|null
Since
5.0

Definition at line 358 of file Service.php.

Member Data Documentation

Elgg\Menu\Service::$menus = []
protected

Definition at line 16 of file Service.php.


The documentation for this class was generated from the following file: