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

Public Member Functions

 __construct ($items)
 constructor More...
 
 getMenu ($sort_by= 'priority')
 Get a prepared menu. 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

Definition at line 13 of file ElggMenuBuilder.php.

Constructor & Destructor Documentation

ElggMenuBuilder::__construct (   $items)

constructor

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

Definition at line 32 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 300 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 321 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 280 of file ElggMenuBuilder.php.

ElggMenuBuilder::filterByContext ( )
protected

Select menu items for the current context.

Returns
MenuItems

Definition at line 72 of file ElggMenuBuilder.php.

ElggMenuBuilder::findSelected ( )
protected

Find the menu item that is currently selected.

Returns
ElggMenuItem|null

Definition at line 209 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 51 of file ElggMenuBuilder.php.

ElggMenuBuilder::getSelected ( )

Get the selected menu item.

Returns
ElggMenuItem|null

Definition at line 63 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 256 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 86 of file ElggMenuBuilder.php.

ElggMenuBuilder::setupSections ( MenuItems  $items)
protected

Group the menu items into sections.

Parameters
MenuItems$itemsItems
Returns
PreparedMenu

Definition at line 101 of file ElggMenuBuilder.php.

ElggMenuBuilder::setupTrees ( PreparedMenu  $menu)
protected

Create trees for each menu section.

Parameters
PreparedMenu$menuPrepared menu
Returns
PreparedMenu

Definition at line 134 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 225 of file ElggMenuBuilder.php.

Member Data Documentation

ElggMenuBuilder::$items
protected

Definition at line 18 of file ElggMenuBuilder.php.

ElggMenuBuilder::$selected_item = null
protected

Definition at line 23 of file ElggMenuBuilder.php.


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