Elgg  Version master
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ElggMenuBuilder Class Reference

Elgg Menu Builder. More...

Public Member Functions

 __construct ($items)
 constructor More...
 
 getMenu ($sort_by= 'priority')
 Get a prepared menu. More...
 
 setSelected (string $item_name)
 Set a menu item as selected. More...
 
 getSelected ()
 Get the selected menu item. More...
 

Static Public Member Functions

static compareByText ($a, $b)
 Compare two menu items by their display text HTML tags are stripped before comparison. More...
 
static compareByName ($a, $b)
 Compare two menu items by their identifiers. More...
 
static compareByPriority ($a, $b)
 Compare two menu items by their priority. More...
 

Protected Member Functions

 filterByContext ()
 Select menu items for the current context. More...
 
 prepare (MenuItems $items, $sort_by= 'priority')
 Prepare a menu. More...
 
 setupSections (MenuItems $items)
 Group the menu items into sections. More...
 
 setupTrees (PreparedMenu $menu)
 Create trees for each menu section. More...
 
 findSelected ()
 Find the menu item that is currently selected. More...
 
 sort (PreparedMenu $menu, $sort_by)
 Sort the menu sections and trees. More...
 
 getSortCallback ($sort_by=null)
 Get callback function for sorting. More...
 

Protected Attributes

 $items
 
 $selected_item = null
 

Detailed Description

Elgg Menu Builder.

Since
1.8.0

Definition at line 12 of file ElggMenuBuilder.php.

Constructor & Destructor Documentation

ElggMenuBuilder::__construct (   $items)

constructor

Parameters
ElggMenuItem[]|MenuItems$items Array of objects
Exceptions

Definition at line 31 of file ElggMenuBuilder.php.

Member Function Documentation

static ElggMenuBuilder::compareByName (   $a,
  $b 
)
static

Compare two menu items by their identifiers.

Parameters
ElggMenuItem$aMenu item
ElggMenuItem$bMenu item
Returns
int

Definition at line 315 of file ElggMenuBuilder.php.

static ElggMenuBuilder::compareByPriority (   $a,
  $b 
)
static

Compare two menu items by their priority.

Parameters
ElggMenuItem$aMenu item
ElggMenuItem$bMenu item
Returns
int
Since
1.9.0

Definition at line 336 of file ElggMenuBuilder.php.

static ElggMenuBuilder::compareByText (   $a,
  $b 
)
static

Compare two menu items by their display text HTML tags are stripped before comparison.

Parameters
ElggMenuItem$aMenu item
ElggMenuItem$bMenu item
Returns
int

Definition at line 295 of file ElggMenuBuilder.php.

ElggMenuBuilder::filterByContext ( )
protected

Select menu items for the current context.

Returns
MenuItems

Definition at line 89 of file ElggMenuBuilder.php.

ElggMenuBuilder::findSelected ( )
protected

Find the menu item that is currently selected.

Returns
ElggMenuItem|null

Definition at line 224 of file ElggMenuBuilder.php.

ElggMenuBuilder::getMenu (   $sort_by = 'priority')

Get a prepared menu.

Parameters
mixed$sort_byMethod to sort the menu by.
See also
::sort()
Returns
PreparedMenu

Definition at line 50 of file ElggMenuBuilder.php.

ElggMenuBuilder::getSelected ( )

Get the selected menu item.

Returns
ElggMenuItem|null

Definition at line 80 of file ElggMenuBuilder.php.

ElggMenuBuilder::getSortCallback (   $sort_by = null)
protected

Get callback function for sorting.

Parameters
string$sort_bySort name
Returns
callable|null

Definition at line 271 of file ElggMenuBuilder.php.

ElggMenuBuilder::prepare ( MenuItems  $items,
  $sort_by = 'priority' 
)
protected

Prepare a menu.

Parameters
MenuItems$itemsMenu items
string$sort_bySorting parameter
Returns
PreparedMenu

Definition at line 103 of file ElggMenuBuilder.php.

ElggMenuBuilder::setSelected ( string  $item_name)

Set a menu item as selected.

Parameters
string$item_namethe menu item name to select
Returns
bool

Definition at line 64 of file ElggMenuBuilder.php.

ElggMenuBuilder::setupSections ( MenuItems  $items)
protected

Group the menu items into sections.

Parameters
MenuItems$itemsItems
Returns
PreparedMenu

Definition at line 117 of file ElggMenuBuilder.php.

ElggMenuBuilder::setupTrees ( PreparedMenu  $menu)
protected

Create trees for each menu section.

Parameters
PreparedMenu$menuPrepared menu
Returns
PreparedMenu

Definition at line 150 of file ElggMenuBuilder.php.

ElggMenuBuilder::sort ( PreparedMenu  $menu,
  $sort_by 
)
protected

Sort the menu sections and trees.

Parameters
PreparedMenu$menuPrepared menu
mixed$sort_bySort type as string or php callback
Returns
PreparedMenu

Definition at line 240 of file ElggMenuBuilder.php.

Member Data Documentation

ElggMenuBuilder::$items
protected

Definition at line 17 of file ElggMenuBuilder.php.

ElggMenuBuilder::$selected_item = null
protected

Definition at line 22 of file ElggMenuBuilder.php.


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