1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\controller_annotations\Configuration; |
4
|
|
|
|
5
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @Annotation |
9
|
|
|
*/ |
10
|
|
|
class Security extends ConfigurationAnnotation |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
protected $permission; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
protected $role; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var bool |
24
|
|
|
*/ |
25
|
|
|
protected $access; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $entity; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var bool |
34
|
|
|
*/ |
35
|
|
|
protected $csrf; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $custom; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
5 |
|
public function hasPermission() |
46
|
|
|
{ |
47
|
5 |
|
return !empty($this->permission); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
5 |
|
public function getPermission() |
54
|
|
|
{ |
55
|
5 |
|
return $this->permission; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $permission |
60
|
|
|
* @return Security |
61
|
|
|
*/ |
62
|
5 |
|
public function setPermission($permission) |
63
|
|
|
{ |
64
|
5 |
|
$this->permission = $permission; |
65
|
|
|
|
66
|
5 |
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return bool |
71
|
|
|
*/ |
72
|
5 |
|
public function hasRole() |
73
|
|
|
{ |
74
|
5 |
|
return !empty($this->role); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return string |
79
|
|
|
*/ |
80
|
5 |
|
public function getRole() |
81
|
|
|
{ |
82
|
5 |
|
return $this->role; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param string $role |
87
|
|
|
* @return Security |
88
|
|
|
*/ |
89
|
5 |
|
public function setRole($role) |
90
|
|
|
{ |
91
|
5 |
|
$this->role = $role; |
92
|
|
|
|
93
|
5 |
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return bool |
98
|
|
|
*/ |
99
|
5 |
|
public function isAccess() |
100
|
|
|
{ |
101
|
5 |
|
return $this->access; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param bool $access |
106
|
|
|
* @return Security |
107
|
|
|
*/ |
108
|
5 |
|
public function setAccess($access) |
109
|
|
|
{ |
110
|
5 |
|
$this->access = $access; |
111
|
|
|
|
112
|
5 |
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return bool |
117
|
|
|
*/ |
118
|
5 |
|
public function hasEntity() |
119
|
|
|
{ |
120
|
5 |
|
return !empty($this->entity); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
5 |
|
public function getEntity() |
127
|
|
|
{ |
128
|
5 |
|
return $this->entity; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $entity |
133
|
|
|
* @return Security |
134
|
|
|
*/ |
135
|
5 |
|
public function setEntity($entity) |
136
|
|
|
{ |
137
|
5 |
|
$this->entity = $entity; |
138
|
|
|
|
139
|
5 |
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return bool |
144
|
|
|
*/ |
145
|
5 |
|
public function hasCustom() |
146
|
|
|
{ |
147
|
5 |
|
return !empty($this->custom); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
5 |
|
public function getCustom() |
154
|
|
|
{ |
155
|
5 |
|
return $this->custom; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param string $custom |
160
|
|
|
* @return Security |
161
|
|
|
*/ |
162
|
5 |
|
public function setCustom($custom) |
163
|
|
|
{ |
164
|
5 |
|
$this->custom = $custom; |
165
|
|
|
|
166
|
5 |
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return bool |
171
|
|
|
*/ |
172
|
5 |
|
public function hasCsrf() |
173
|
|
|
{ |
174
|
5 |
|
return !empty($this->csrf); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @param bool $csrf |
179
|
|
|
* @return Security |
180
|
|
|
*/ |
181
|
5 |
|
public function setCsrf($csrf) |
182
|
|
|
{ |
183
|
5 |
|
$this->csrf = $csrf; |
184
|
|
|
|
185
|
5 |
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
5 |
|
public function getAliasName() |
189
|
|
|
{ |
190
|
5 |
|
return 'security'; |
191
|
|
|
} |
192
|
|
|
|
193
|
5 |
|
public function allowArray() |
194
|
|
|
{ |
195
|
5 |
|
return false; |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|