Piwik\Menu\

MenuAbstract

Base class for classes that manage one of Matomo (formerly Piwik)'s menus.

There are three menus in Matomo, 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.

Methods

The abstract class defines the following methods:

  • getInstance() ash; Returns the singleton instance for the derived class. Inherited from Singleton
  • addItem() — Adds a new entry to the menu.
  • remove() — Removes an existing entry from the menu.
  • rename() — Renames a single menu entry.
  • editUrl() — Edits a URL of an existing menu entry.

getInstance()

Returns the singleton instance for the derived class.

If the singleton instance has not been created, this method will create it.

Signature

addItem()

Since Matomo 2.7.0

Adds a new entry to the menu.

Signature

  • It accepts the following parameter(s):
    • $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 (int) — The order hint.
    • $tooltip (bool|string) — An optional tooltip to display or false to display the tooltip.
    • $icon (bool|string) — An icon classname, such as "icon-add". Only supported by admin menu
    • $onclick (bool|string) — Will execute the on click handler instead of executing the link. Only supported by admin menu.
  • It does not return anything.

remove()

Removes an existing entry from the menu.

Signature

  • It accepts the following parameter(s):
    • $menuName (string) — The menu's category name. Can be a translation token.
    • $subMenuName (bool|string) — The menu item's name. Can be a translation token.
  • It does not return anything.

rename()

Renames a single menu entry.

Signature

  • It accepts the following parameter(s):

    • $mainMenuOriginal (Piwik\Menu\$mainMenuOriginal) —

    • $subMenuOriginal (Piwik\Menu\$subMenuOriginal) —

    • $mainMenuRenamed (Piwik\Menu\$mainMenuRenamed) —

    • $subMenuRenamed (Piwik\Menu\$subMenuRenamed) —

  • It does not return anything.

editUrl()

Edits a URL of an existing menu entry.

Signature

  • It accepts the following parameter(s):

    • $mainMenuToEdit (Piwik\Menu\$mainMenuToEdit) —

    • $subMenuToEdit (Piwik\Menu\$subMenuToEdit) —

    • $newUrl (Piwik\Menu\$newUrl) —

  • It does not return anything.