-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNavbarSubmenuItem.php
More file actions
91 lines (75 loc) · 1.73 KB
/
Copy pathNavbarSubmenuItem.php
File metadata and controls
91 lines (75 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace ADT\FancyAdmin\Model\Menu;
use ADT\FancyAdmin\Model\Security\SecurityUser;
use Nette\Application\UI\Component;
use Nette\Security\Resource;
class NavbarSubmenuItem
{
protected string $label = 'Test';
protected string $faIcon = 'chart-simple';
protected string $link = '#';
protected array $linkArgs = [];
protected ?Resource $resource = null;
protected ?\Closure $condition = null;
public function getLabel(): string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getLink(): string
{
return $this->link;
}
public function setLink(string $link): self
{
$this->link = $link;
return $this;
}
public function getLinkArgs(): array
{
return $this->linkArgs;
}
public function setLinkArgs(array $linkArgs): self
{
$this->linkArgs = $linkArgs;
return $this;
}
public function getFaIcon(): string
{
return $this->faIcon;
}
public function setFaIcon(string $faIcon): self
{
$this->faIcon = $faIcon;
return $this;
}
public function isCurrent(Component $presenter): bool
{
return $presenter->isLinkCurrent($this->getLink(), $this->getLinkArgs());
}
public function getAclResource(): ?Resource
{
return $this->resource;
}
public function setAclResource(?Resource $resource): self
{
$this->resource = $resource;
return $this;
}
public function setCondition(\Closure $condition): self
{
$this->condition = $condition;
return $this;
}
public function isVisible(SecurityUser $user, Component $presenter): bool
{
if ($this->getAclResource() && !$user->isAllowed($this->getAclResource())) {
return false;
}
return $this->condition === null || ($this->condition)($user, $presenter);
}
}