1 | <?php |
||
16 | class MenuArea extends MenuItem |
||
17 | { |
||
18 | /** @var callable $function function to call when area is selected. */ |
||
19 | protected $function; |
||
20 | |||
21 | /** @var string $icon File name of an icon to use on the menu, if using the sprite class, set as transparent.png */ |
||
22 | protected $icon = ''; |
||
23 | |||
24 | /** @var string $controller URL to use for this menu item. */ |
||
25 | protected $controller = ''; |
||
26 | |||
27 | /** @var string $select References another area to be highlighted while this one is active */ |
||
28 | public $select = ''; |
||
29 | |||
30 | /** @var string $class Class name to apply to the icon img, used to apply a sprite icon */ |
||
31 | protected $class = ''; |
||
32 | |||
33 | /** @var bool $enabled Should this area even be accessible? */ |
||
34 | protected $enabled = true; |
||
35 | |||
36 | /** @var bool $hidden Should this area be visible? */ |
||
37 | protected $hidden = false; |
||
38 | |||
39 | /** @var array $subsections Array of subsections from this area. */ |
||
40 | private $subsections = []; |
||
41 | |||
42 | /** |
||
43 | * @param array $arr |
||
44 | * |
||
45 | * @return MenuArea |
||
46 | */ |
||
47 | 41 | protected function buildMoreFromArray(array $arr): MenuArea |
|
48 | { |
||
49 | 41 | if (isset($arr['custom_url'])) |
|
50 | { |
||
51 | 2 | $this->setUrl($arr['custom_url']); |
|
52 | } |
||
53 | 41 | if (isset($arr['subsections'])) |
|
54 | { |
||
55 | 41 | foreach ($arr['subsections'] as $var => $subsection) |
|
56 | { |
||
57 | 41 | $this->addSubsection($var, $subsection); |
|
58 | } |
||
59 | } |
||
60 | |||
61 | 41 | return $this; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param string $id |
||
66 | * @param MenuSubsection $subsection |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | 41 | public function addSubsection(string $id, MenuSubsection $subsection): MenuArea |
|
76 | |||
77 | /** |
||
78 | * @return callable |
||
79 | */ |
||
80 | 1 | public function getFunction() |
|
84 | |||
85 | /** |
||
86 | * @param callable $function |
||
87 | * |
||
88 | * @return MenuArea |
||
89 | */ |
||
90 | 41 | public function setFunction($function): MenuArea |
|
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | 38 | public function getIcon(): string |
|
104 | |||
105 | /** |
||
106 | * @param string $icon |
||
107 | * |
||
108 | * @return MenuArea |
||
109 | */ |
||
110 | 41 | public function setIcon(string $icon): MenuArea |
|
116 | |||
117 | /** |
||
118 | * @return string |
||
119 | */ |
||
120 | 1 | public function getController(): string |
|
124 | |||
125 | /** |
||
126 | * @param string $controller |
||
127 | * |
||
128 | * @return MenuArea |
||
129 | */ |
||
130 | 41 | public function setController(string $controller): MenuArea |
|
136 | |||
137 | /** |
||
138 | * @return string |
||
139 | */ |
||
140 | 38 | public function getSelect(): string |
|
144 | |||
145 | /** |
||
146 | * @param string $select |
||
147 | * |
||
148 | * @return MenuArea |
||
149 | */ |
||
150 | 41 | public function setSelect(string $select): MenuArea |
|
156 | |||
157 | /** |
||
158 | * @return string |
||
159 | */ |
||
160 | 1 | public function getClass(): string |
|
164 | |||
165 | /** |
||
166 | * @param string $class |
||
167 | * |
||
168 | * @return MenuArea |
||
169 | */ |
||
170 | 41 | public function setClass(string $class): MenuArea |
|
176 | |||
177 | /** |
||
178 | * @return boolean |
||
179 | */ |
||
180 | 38 | public function isHidden(): bool |
|
184 | |||
185 | /** |
||
186 | * @param boolean $hidden |
||
187 | * |
||
188 | * @return MenuArea |
||
189 | */ |
||
190 | 41 | public function setHidden(bool $hidden): MenuArea |
|
196 | |||
197 | /** |
||
198 | * @return array |
||
199 | */ |
||
200 | 38 | public function toArray(): array |
|
204 | |||
205 | /** |
||
206 | * @return array |
||
207 | */ |
||
208 | 39 | public function getSubsections(): array |
|
212 | } |
||
213 |