Elgg  Version master
UnpreparedMenu.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Menu;
4 
6 
13 
17  private $items;
18 
22  private $params;
23 
31  public function __construct(array $params, $items) {
32  $this->params = $params;
33 
34  if (is_array($items)) {
35  $items = new MenuItems($items);
36  }
37 
38  if (!$items instanceof MenuItems) {
39  throw new InvalidArgumentException('Items collection must implement ' . MenuItems::class);
40  }
41 
42  $this->items = $items;
43  }
44 
54  public function setSortBy($sort_by = 'text') {
55  $this->params['sort_by'] = $sort_by;
56  }
57 
66  public function getSortBy() {
67  return elgg_extract('sort_by', $this->params, 'priority');
68  }
69 
75  public function getName() {
76  return $this->params['name'];
77  }
78 
84  public function getItems() {
85  return $this->items;
86  }
87 
93  public function getParams() {
94  return $this->params;
95  }
96 }
Exception thrown if an argument is not of the expected type.
getSortBy()
Get the designated (or default) sort strategy.
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
getParams()
Get the menu parameters.
setSortBy($sort_by= 'text')
Set how this menu should be sorted.
Linear set of menu items collected from configuration and the "register" event.
getName()
Get the menu name.
__construct(array $params, $items)
Constructor.
getItems()
Get the menu items.
A collection of menu items.
Definition: MenuItems.php:10