Elgg
Version master
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
classes
Elgg
Menu
UnpreparedMenu.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\Menu
;
4
5
use
Elgg\Exceptions\InvalidArgumentException
;
6
use
ElggMenuItem
;
7
13
class
UnpreparedMenu
{
14
18
private
$items;
19
23
private
$params;
24
32
public
function
__construct
(array $params, $items) {
33
$this->params = $params;
34
35
if
(is_array($items)) {
36
$items =
new
MenuItems
($items);
37
}
38
39
if
(!$items instanceof
MenuItems
) {
40
throw
new
InvalidArgumentException
(
'Items collection must implement '
. MenuItems::class);
41
}
42
43
$this->items = $items;
44
}
45
55
public
function
setSortBy
($sort_by =
'text'
) {
56
$this->params[
'sort_by'
] = $sort_by;
57
}
58
67
public
function
getSortBy
() {
68
return
elgg_extract
(
'sort_by'
, $this->params,
'priority'
);
69
}
70
76
public
function
getName
() {
77
return
$this->params[
'name'
];
78
}
79
85
public
function
getItems
() {
86
return
$this->items;
87
}
88
94
public
function
getParams
() {
95
return
$this->params;
96
}
97
}
Elgg\Exceptions\InvalidArgumentException
Exception thrown if an argument is not of the expected type.
Definition:
InvalidArgumentException.php:11
Elgg\Menu\UnpreparedMenu\getSortBy
getSortBy()
Get the designated (or default) sort strategy.
Definition:
UnpreparedMenu.php:67
ElggMenuItem
Elgg\Menu
Definition:
Menu.php:3
elgg_extract
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition:
elgglib.php:254
Elgg\Menu\UnpreparedMenu\getParams
getParams()
Get the menu parameters.
Definition:
UnpreparedMenu.php:94
Elgg\Menu\UnpreparedMenu\setSortBy
setSortBy($sort_by= 'text')
Set how this menu should be sorted.
Definition:
UnpreparedMenu.php:55
Elgg\Menu\UnpreparedMenu
Linear set of menu items collected from configuration and the "register" event.
Definition:
UnpreparedMenu.php:13
Elgg\Menu\UnpreparedMenu\getName
getName()
Get the menu name.
Definition:
UnpreparedMenu.php:76
InvalidArgumentException
Elgg\Menu\UnpreparedMenu\__construct
__construct(array $params, $items)
Constructor.
Definition:
UnpreparedMenu.php:32
Elgg\Menu\UnpreparedMenu\getItems
getItems()
Get the menu items.
Definition:
UnpreparedMenu.php:85
Elgg\Menu\MenuItems
A collection of menu items.
Definition:
MenuItems.php:10
Generated on Wed Dec 6 2023 00:02:00 for Elgg by
1.8.11