PHP Class Piwik\Menu\MenuAbstract

There are three menus in Piwik, the main menu, the top menu and the admin menu. Each menu has a class that manages the menu's content. Each class invokes a different event to allow plugins to add new menu items.
Inheritance: extends Piwik\Singleton
显示文件 Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$edits
$menu
$menuEntries
$menuEntriesToRemove
$menuIcons
$menus
$orderingApplied
$renames

Public Methods

Method Description
addItem ( string $menuName, string $subMenuName, string | array $url, integer $order = 50, boolean | string $tooltip = false ) Adds a new entry to the menu.
clearMenus ( ) To use only for tests.
editUrl ( $mainMenuToEdit, $subMenuToEdit, $newUrl ) Edits a URL of an existing menu entry.
getMenu ( ) : Array Builds the menu, applies edits, renames and orders the entries.
registerMenuIcon ( string $menuName, string $iconCssClass ) lets you register a menu icon for a certain menu category to replace the default arrow icon.
remove ( string $menuName, boolean | string $subMenuName = false ) Removes an existing entry from the menu.
rename ( $mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed ) Renames a single menu entry.

Protected Methods

Method Description
getAllMenus ( ) : Menu[] Returns a list of available plugin menu instances.
menuCompare ( array $itemOne, array $itemTwo ) : boolean Compares two menu entries. Used for ordering.

Private Methods

Method Description
applyEdits ( ) Applies all edits to the menu.
applyOrdering ( ) Orders the menu according to their order.
applyRemoves ( )
applyRenames ( ) Applies renames to the menu.
buildMenu ( ) Builds the menu from the $this->menuEntries variable.
buildMenuItem ( string $menuName, string $subMenuName, string $url, integer $order = 50, boolean | string $tooltip = false ) Builds a single menu item

Method Details

addItem() public method

Adds a new entry to the menu.
Since: 2.7.0
public addItem ( string $menuName, string $subMenuName, string | array $url, integer $order = 50, boolean | string $tooltip = false )
$menuName string The menu's category name. Can be a translation token.
$subMenuName string The menu item's name. Can be a translation token.
$url string | array The URL the admin menu entry should link to, or an array of query parameters that can be used to build the URL.
$order integer The order hint.
$tooltip boolean | string An optional tooltip to display or false to display the tooltip.

clearMenus() public static method

To use only for tests.
Deprecation: The whole $menus cache should be replaced by a real transient cache
public static clearMenus ( )

editUrl() public method

Edits a URL of an existing menu entry.
public editUrl ( $mainMenuToEdit, $subMenuToEdit, $newUrl )
$mainMenuToEdit
$subMenuToEdit
$newUrl

getAllMenus() protected method

Returns a list of available plugin menu instances.
protected getAllMenus ( ) : Menu[]
return Piwik\Plugin\Menu[]

getMenu() public method

Builds the menu, applies edits, renames and orders the entries.
public getMenu ( ) : Array
return Array

menuCompare() protected method

Compares two menu entries. Used for ordering.
protected menuCompare ( array $itemOne, array $itemTwo ) : boolean
$itemOne array
$itemTwo array
return boolean

registerMenuIcon() public method

lets you register a menu icon for a certain menu category to replace the default arrow icon.
public registerMenuIcon ( string $menuName, string $iconCssClass )
$menuName string The translation key of a main menu category, eg 'Dashboard_Dashboard'
$iconCssClass string The css class name of an icon, eg 'icon-user'

remove() public method

Removes an existing entry from the menu.
public remove ( string $menuName, boolean | string $subMenuName = false )
$menuName string The menu's category name. Can be a translation token.
$subMenuName boolean | string The menu item's name. Can be a translation token.

rename() public method

Renames a single menu entry.
public rename ( $mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed )
$mainMenuOriginal
$subMenuOriginal
$mainMenuRenamed
$subMenuRenamed

Property Details

$edits protected_oe property

protected $edits

$menu protected_oe property

protected $menu

$menuEntries protected_oe property

protected $menuEntries

$menuEntriesToRemove protected_oe property

protected $menuEntriesToRemove

$menuIcons protected_oe property

protected $menuIcons

$menus protected_oe static_oe property

protected static $menus

$orderingApplied protected_oe property

protected $orderingApplied

$renames protected_oe property

protected $renames