1 | <?php |
||
14 | 1 | class MenuItem { |
|
15 | 1 | use \Nette\SmartObject; |
|
16 | |||
17 | /** @var string */ |
||
18 | protected $text; |
||
19 | /** @var string */ |
||
20 | protected $link; |
||
21 | /** @var array of [IMenuItemCondition, parameter] */ |
||
22 | protected $conditions = []; |
||
23 | /** @var IMenuItemLinkRender[] */ |
||
24 | protected $linkRenders = []; |
||
25 | |||
26 | public function __construct(string $link, string $text) { |
||
27 | 1 | $this->link = $link; |
|
28 | 1 | $this->text = $text; |
|
29 | 1 | } |
|
30 | |||
31 | public function getLink(): string { |
||
32 | 1 | $link = $this->link; |
|
33 | 1 | foreach($this->linkRenders as $render) { |
|
34 | 1 | if($render->isApplicable($this->link)) { |
|
35 | 1 | $link = $render->renderLink($this->link); |
|
36 | 1 | break; |
|
37 | } |
||
38 | } |
||
39 | 1 | return $link; |
|
40 | } |
||
41 | |||
42 | public function setLink(string $link) { |
||
43 | 1 | $this->link = $link; |
|
44 | 1 | } |
|
45 | |||
46 | public function getText(): string { |
||
49 | |||
50 | public function setText(string $text) { |
||
51 | 1 | $this->text = $text; |
|
52 | 1 | } |
|
53 | |||
54 | /** |
||
55 | * @param mixed $parameter |
||
56 | */ |
||
57 | public function addCondition(IMenuItemCondition $condition, $parameter): void { |
||
60 | |||
61 | public function addLinkRender(IMenuItemLinkRender $render): void { |
||
64 | |||
65 | public function isAllowed(): bool { |
||
73 | } |
||
74 | ?> |