AbstractMenu
Menu class
| since |
1.5 |
|---|---|
| note |
Will become abstract in Joomla 4 |
| package |
Joomla CMS |
Methods
__construct
Class constructor
__construct(array options = array()) : mixed
| since |
1.5 |
|---|
Arguments
- options
arrayAn array of configuration options.
Response
mixed
__get
Magic getter for the user object. Returns the injected one if any, or the current one if none.
__get(string propName) : \Joomla\CMS\User\User|null
Using a magic getter to preserve B/C when we stopped storing the user object upon construction of the menu object. As the user property is not initialized anymore, this getter ensures any class extending this one can still use $instance->user and get a proper value.
| since |
3.9.26 |
|---|
Arguments
- propName
stringName of the missing or protected property.
Response
\Joomla\CMS\User\User|null
authorise
Method to check Menu object authorization against an access control object and optionally an access extension object
authorise(int id) : bool
| since |
1.5 |
|---|
Arguments
- id
intThe menu id
Response
bool
getActive
Get menu item by id.
getActive() : \Joomla\CMS\Menu\MenuItem|null
| since |
1.5 |
|---|
Response
\Joomla\CMS\Menu\MenuItem|nullThe item object if an active menu item has been set or null
getDefault
Get the default item by language code.
getDefault(string language = '*') : \Joomla\CMS\Menu\MenuItem|null
| since |
1.5 |
|---|
Arguments
- language
stringThe language code, default value of * means all.
Response
\Joomla\CMS\Menu\MenuItem|nullThe item object or null when not found for given language
getInstance
Returns a Menu object
getInstance(string client, array options = array()) : \Joomla\CMS\Menu\AbstractMenu
| throws |
|
|---|---|
| since |
1.5 |
Arguments
- client
stringThe name of the client- options
arrayAn associative array of options
Response
\Joomla\CMS\Menu\AbstractMenuA menu object.
getItem
Get menu item by id
getItem(int id) : \Joomla\CMS\Menu\MenuItem|null
| since |
1.5 |
|---|
Arguments
- id
intThe item id
Response
\Joomla\CMS\Menu\MenuItem|nullThe item object if the ID exists or null if not found
getItems
Gets menu items by attribute
getItems(mixed attributes, mixed values, bool firstonly = false) : \Joomla\CMS\Menu\MenuItem|\Joomla\CMS\Menu\MenuItem[]
| since |
1.5 |
|---|
Arguments
- attributes
mixedThe field name(s).- values
mixedThe value(s) of the field. If an array, need to match field names each attribute may have multiple values to lookup for.- firstonly
boolIf true, only returns the first item found
Response
\Joomla\CMS\Menu\MenuItem|\Joomla\CMS\Menu\MenuItem[]An array of menu item objects or a single object if the $firstonly parameter is true
getMenu
Getter for the menu array
getMenu() : \Joomla\CMS\Menu\MenuItem[]
| since |
1.5 |
|---|
Response
\Joomla\CMS\Menu\MenuItem[]
getParams
Gets the parameter object for a certain menu item
getParams(int id) : \Joomla\Registry\Registry
| since |
1.5 |
|---|
Arguments
- id
intThe item id
Response
\Joomla\Registry\Registry
getUser
Internal getter for the user. Returns the injected one if any, or the current one if none.
getUser() : \Joomla\CMS\User\User
| since |
3.9.26 |
|---|
Response
\Joomla\CMS\User\User
load
Loads the menu items
load() : array
| since |
1.5 |
|---|
Response
array
setActive
Set the default item by id
setActive(int id) : \Joomla\CMS\Menu\MenuItem|null
| since |
1.5 |
|---|
Arguments
- id
intThe item id
Response
\Joomla\CMS\Menu\MenuItem|nullThe menu item representing the given ID if present or null otherwise
setDefault
Set the default item by id and language code.
setDefault(int id, string language = '*') : bool
| since |
1.5 |
|---|
Arguments
- id
intThe menu item id.- language
stringThe language code (since 1.6).
Response
boolTrue if a menu item with the given ID exists
setUser
Setter for the current user used to build menu.
setUser(\Joomla\CMS\User\User user) : null
| since |
3.9.26 |
|---|
Arguments
- user
\Joomla\CMS\User\UserThe new user to set.
Response
null
Properties
_items
Array to hold the menu items
| since |
1.5 |
|---|---|
| deprecated |
4.0 Will convert to $items |
Type(s)
\Joomla\CMS\Menu\MenuItem[]
_default
Identifier of the default menu item
| since |
1.5 |
|---|---|
| deprecated |
4.0 Will convert to $default |
Type(s)
int
_active
Identifier of the active menu item
| since |
1.5 |
|---|---|
| deprecated |
4.0 Will convert to $active |
Type(s)
int
instances
Menu instances container.
| since |
1.7 |
|---|
Type(s)
\Joomla\CMS\Menu\AbstractMenu[]
storedUser
User object to check access levels for
| since |
3.9.26 |
|---|
Type(s)
\Joomla\CMS\User\User