Elgg  Version master
UnpreparedMenu.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Menu;
4 
6 use ElggMenuItem;
7 
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 }
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