1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Silverback\ApiComponentBundle\Entity\Component\Navigation; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Silverback\ApiComponentBundle\Entity\Component\AbstractComponent; |
9
|
|
|
use Silverback\ApiComponentBundle\Entity\Route\Route; |
10
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
11
|
|
|
|
12
|
|
|
abstract class AbstractNavigationItem extends AbstractComponent implements NavigationItemInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @ORM\Column() |
16
|
|
|
* @Groups({"layout", "content", "component"}) |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $label; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @ORM\ManyToOne(targetEntity="Silverback\ApiComponentBundle\Entity\Route\Route", cascade={"persist"}) |
23
|
|
|
* @ORM\JoinColumn(referencedColumnName="id", onDelete="SET NULL") |
24
|
|
|
* @Groups({"layout", "content", "component"}) |
25
|
|
|
* @var null|Route |
26
|
|
|
*/ |
27
|
|
|
protected $route; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @ORM\Column(nullable=true) |
31
|
|
|
* @Groups({"layout", "content", "component"}) |
32
|
|
|
* @var null|string |
33
|
|
|
*/ |
34
|
|
|
protected $fragment; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @ORM\Column(type="array", nullable=true) |
38
|
|
|
* @Groups({"layout", "content", "component"}) |
39
|
|
|
* @var null|array |
40
|
|
|
*/ |
41
|
|
|
protected $roles; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @ORM\Column(type="array", nullable=true) |
45
|
|
|
* @Groups({"layout", "content", "component"}) |
46
|
|
|
* @var null|array |
47
|
|
|
*/ |
48
|
|
|
protected $excludeRoles; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
public function getLabel(): string |
54
|
|
|
{ |
55
|
|
|
return $this->label; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $label |
60
|
|
|
* @return AbstractNavigationItem |
61
|
|
|
*/ |
62
|
|
|
public function setLabel(string $label): AbstractNavigationItem |
63
|
|
|
{ |
64
|
|
|
$this->label = $label; |
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return null|Route |
70
|
|
|
*/ |
71
|
|
|
public function getRoute(): ?Route |
72
|
|
|
{ |
73
|
|
|
return $this->route; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param null|Route $route |
78
|
|
|
* @return AbstractNavigationItem |
79
|
|
|
*/ |
80
|
|
|
public function setRoute(?Route $route): AbstractNavigationItem |
81
|
|
|
{ |
82
|
|
|
$this->route = $route; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return null|string |
88
|
|
|
*/ |
89
|
|
|
public function getFragment(): ?string |
90
|
|
|
{ |
91
|
|
|
return $this->fragment; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param null|string $fragment |
96
|
|
|
* @return AbstractNavigationItem |
97
|
|
|
*/ |
98
|
|
|
public function setFragment(?string $fragment): AbstractNavigationItem |
99
|
|
|
{ |
100
|
|
|
$this->fragment = $fragment; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return null|array |
106
|
|
|
*/ |
107
|
|
|
public function getRoles(): ?array |
108
|
|
|
{ |
109
|
|
|
return $this->roles; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param null|array $roles |
114
|
|
|
* @return self |
115
|
|
|
*/ |
116
|
|
|
public function setRoles(?array $roles): self |
117
|
|
|
{ |
118
|
|
|
$this->roles = $roles; |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return null|array |
124
|
|
|
*/ |
125
|
|
|
public function getExcludeRoles(): ?array |
126
|
|
|
{ |
127
|
|
|
return $this->excludeRoles; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @param null|array $excludeRoles |
132
|
|
|
* @return self |
133
|
|
|
*/ |
134
|
|
|
public function setExcludeRoles(?array $excludeRoles): self |
135
|
|
|
{ |
136
|
|
|
$this->excludeRoles = $excludeRoles; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|