Since: 1.5

class AdministratorMenu extends AbstractMenu

Menu class.

Properties

protected MenuItem[] Since: 4.0.0
$items

Array to hold the menu items

from  AbstractMenu
protected int[] Since: 4.0.0
$default

Identifier of the default menu item. Key of the array is the language.

from  AbstractMenu
protected int Since: 4.0.0
$active

Identifier of the active menu item

from  AbstractMenu
static AbstractMenu[] deprecated Since: 1.7
$instances

Menu instances container.

from  AbstractMenu
protected User Since: 3.9.26
$storedUser

User object to check access levels for

from  AbstractMenu

Methods

__construct(array $options = [])

Class constructor

static AbstractMenu
getInstance(string $client, array $options = []) deprecated

Returns a Menu object

void
setUser(User $user)

Setter for the current user used to build menu.

MenuItem|null
getItem(int $id)

Get menu item by id

bool
setDefault(int $id, string $language = '*')

Set the default item by id and language code.

MenuItem|null
getDefault(string $language = '*')

Get the default item by language code.

MenuItem|null
setActive(int $id)

Set the default item by id

MenuItem|null
getActive()

Get menu item by id.

getItems(mixed $attributes, mixed $values, bool $firstonly = false)

Gets menu items by attribute

Registry
getParams(int $id)

Gets the parameter object for a certain menu item

getMenu()

Getter for the menu array

bool
authorise(int $id)

Method to check Menu object authorization against an access control object and optionally an access extension object

array
load()

Loads the menu items

getUser()

Internal getter for the user. Returns the injected one if any, or the current one if none.

User|null
__get(string $propName)

Magic getter for the user object. Returns the injected one if any, or the current one if none.

Details

__construct(array $options = [])

Since: 1.5

Class constructor

Parameters

array $options

An array of configuration options.

static AbstractMenu getInstance(string $client, array $options = []) deprecated

Since: 1.5

deprecated 4.3 will be removed in 6.0 Use the MenuFactoryInterface from the container instead Example: Factory::getContainer()->get(MenuFactoryInterface::class)->createMenu($client, $options)

Returns a Menu object

Parameters

string $client

The name of the client

array $options

An associative array of options

Return Value

AbstractMenu

A menu object.

Exceptions

Exception

void setUser(User $user)

Since: 3.9.26

Setter for the current user used to build menu.

Parameters

User $user

The new user to set.

Return Value

void

MenuItem|null getItem(int $id)

Since: 1.5

Get menu item by id

Parameters

int $id

The item id

Return Value

MenuItem|null

The item object if the ID exists or null if not found

bool setDefault(int $id, string $language = '*')

Since: 1.5

Set the default item by id and language code.

Parameters

int $id

The menu item id.

string $language

The language code (since 1.6).

Return Value

bool

True if a menu item with the given ID exists

MenuItem|null getDefault(string $language = '*')

Since: 1.5

Get the default item by language code.

Parameters

string $language

The language code, default value of * means all.

Return Value

MenuItem|null

The item object or null when not found for given language

MenuItem|null setActive(int $id)

Since: 1.5

Set the default item by id

Parameters

int $id

The item id

Return Value

MenuItem|null

The menu item representing the given ID if present or null otherwise

MenuItem|null getActive()

Since: 1.5

Get menu item by id.

Return Value

MenuItem|null

The item object if an active menu item has been set or null

MenuItem|MenuItem[] getItems(mixed $attributes, mixed $values, bool $firstonly = false)

Since: 1.5

Gets menu items by attribute

Parameters

mixed $attributes

The field name(s).

mixed $values

The value(s) of the field. If an array, need to match field names each attribute may have multiple values to lookup for.

bool $firstonly

If true, only returns the first item found

Return Value

MenuItem|MenuItem[]

An array of menu item objects or a single object if the $firstonly parameter is true

Registry getParams(int $id)

Since: 1.5

Gets the parameter object for a certain menu item

Parameters

int $id

The item id

Return Value

Registry

MenuItem[] getMenu()

Since: 1.5

Getter for the menu array

Return Value

MenuItem[]

bool authorise(int $id)

Since: 1.5

Method to check Menu object authorization against an access control object and optionally an access extension object

Parameters

int $id

The menu id

Return Value

bool

array load()

Since: 4.0.0

Loads the menu items

Return Value

array

protected User getUser()

Since: 3.9.26

Internal getter for the user. Returns the injected one if any, or the current one if none.

Return Value

User

User|null __get(string $propName)

Since: 3.9.26

Magic getter for the user object. Returns the injected one if any, or the current one if none.

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.

Parameters

string $propName

Name of the missing or protected property.

Return Value

User|null