Elgg  Version 6.2
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 }
$params
Saves global plugin settings.
Definition: save.php:13
Exception thrown if an argument is not of the expected type.
A collection of menu items.
Definition: MenuItems.php:10
Linear set of menu items collected from configuration and the "register" event.
getName()
Get the menu name.
getItems()
Get the menu items.
getParams()
Get the menu parameters.
getSortBy()
Get the designated (or default) sort strategy.
__construct(array $params, $items)
Constructor.
setSortBy($sort_by='text')
Set how this menu should be sorted.
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:256