PHP Class ElggMenuBuilder, Elgg

Since: 1.8.0
显示文件 Open project: elgg/elgg Class Usage Examples

Protected Properties

Property Type Description
$menu ElggMenuItem[]
$selected

Public Methods

Method Description
__construct ( array $menu ) \ElggMenuBuilder constructor
compareByName ( ElggMenuItem $a, ElggMenuItem $b ) : boolean Compare two menu items by their identifiers
compareByPriority ( ElggMenuItem $a, ElggMenuItem $b ) : boolean Compare two menu items by their priority
compareByText ( ElggMenuItem $a, ElggMenuItem $b ) : boolean Compare two menu items by their display text HTML tags are stripped before comparison
getMenu ( mixed $sort_by = 'text' ) : array Get a prepared menu array
getSelected ( ) : ElggMenuItem Get the selected menu item

Protected Methods

Method Description
findSelected ( ) : ElggMenuItem Find the menu item that is currently selected
selectFromContext ( ) : void Select menu items for the current context
setupSections ( ) : void Group the menu items into sections
setupTrees ( ) : void Create trees for each menu section
sort ( mixed $sort_by ) : void Sort the menu sections and trees

Method Details

__construct() public method

\ElggMenuBuilder constructor
public __construct ( array $menu )
$menu array Array of \ElggMenuItem objects

compareByName() public static method

Compare two menu items by their identifiers
public static compareByName ( ElggMenuItem $a, ElggMenuItem $b ) : boolean
$a ElggMenuItem Menu item
$b ElggMenuItem Menu item
return boolean

compareByPriority() public static method

Compare two menu items by their priority
Since: 1.9.0
public static compareByPriority ( ElggMenuItem $a, ElggMenuItem $b ) : boolean
$a ElggMenuItem Menu item
$b ElggMenuItem Menu item
return boolean

compareByText() public static method

Compare two menu items by their display text HTML tags are stripped before comparison
public static compareByText ( ElggMenuItem $a, ElggMenuItem $b ) : boolean
$a ElggMenuItem Menu item
$b ElggMenuItem Menu item
return boolean

findSelected() protected method

Find the menu item that is currently selected
protected findSelected ( ) : ElggMenuItem
return ElggMenuItem

getMenu() public method

Get a prepared menu array
public getMenu ( mixed $sort_by = 'text' ) : array
$sort_by mixed Method to sort the menu by. @see \ElggMenuBuilder::sort()
return array

getSelected() public method

Get the selected menu item
public getSelected ( ) : ElggMenuItem
return ElggMenuItem

selectFromContext() protected method

Select menu items for the current context
protected selectFromContext ( ) : void
return void

setupSections() protected method

Group the menu items into sections
protected setupSections ( ) : void
return void

setupTrees() protected method

Create trees for each menu section
protected setupTrees ( ) : void
return void

sort() protected method

Sort the menu sections and trees
protected sort ( mixed $sort_by ) : void
$sort_by mixed Sort type as string or php callback
return void

Property Details

$menu protected_oe property

protected ElggMenuItem[] $menu
return ElggMenuItem[]

$selected protected_oe property

protected $selected