Elgg  Version 3.0
UnpreparedMenu.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Menu;
4 
5 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  $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 }
getSortBy()
Get the designated (or default) sort strategy.
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" hook.
getName()
Get the menu name.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
class
Definition: placeholder.php:21
__construct(array $params, $items)
Constructor.
getItems()
Get the menu items.
A collection of menu items.
Definition: MenuItems.php:10