1 | <?php |
||
18 | trait GroupPropertiesTrait |
||
19 | { |
||
20 | /** |
||
21 | * @ORM\Id |
||
22 | * @ORM\Column(type="integer") |
||
23 | * @ORM\GeneratedValue(strategy="AUTO") |
||
24 | */ |
||
25 | protected $id; |
||
26 | |||
27 | /** |
||
28 | * @Assert\NotBlank() |
||
29 | * @ORM\Column(type="string") |
||
30 | */ |
||
31 | protected $name; |
||
32 | |||
33 | /** |
||
34 | * @ORM\ManyToMany(targetEntity="Role") |
||
35 | * @ORM\JoinTable(name="kuma_groups_roles", |
||
36 | * joinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}, |
||
37 | * inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")} |
||
38 | * ) |
||
39 | */ |
||
40 | protected $roles; |
||
41 | |||
42 | /** |
||
43 | * Construct a new group |
||
44 | * |
||
45 | * @param string $name Name of the group |
||
46 | */ |
||
47 | 13 | public function __construct($name = '') |
|
52 | |||
53 | /** |
||
54 | * Get id |
||
55 | * |
||
56 | * @return int |
||
57 | */ |
||
58 | 1 | public function getId() |
|
62 | |||
63 | /** |
||
64 | * Get string representation of object |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | 1 | public function __toString() |
|
72 | |||
73 | /** |
||
74 | * Returns an array of strings (needed because Symfony ACL doesn't support using RoleInterface yet) |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | 4 | public function getRoles() |
|
88 | |||
89 | /** |
||
90 | * Returns the true ArrayCollection of Roles. |
||
91 | * |
||
92 | * @return ArrayCollection |
||
93 | */ |
||
94 | 2 | public function getRolesCollection() |
|
98 | |||
99 | /** |
||
100 | * Pass a string, get the desired Role object or null. |
||
101 | * |
||
102 | * @param string $role |
||
|
|||
103 | * |
||
104 | * @return Role|null |
||
105 | */ |
||
106 | 7 | public function getRole($role = null) |
|
117 | |||
118 | /** |
||
119 | * Pass a string, checks if we have that Role. Same functionality as getRole() except it returns a boolean. |
||
120 | * |
||
121 | * @param string $role |
||
122 | * |
||
123 | * @return bool |
||
124 | */ |
||
125 | 7 | public function hasRole($role) |
|
133 | |||
134 | /** |
||
135 | * Adds a Role object to the ArrayCollection. Can't type hint due to interface so throws Exception. |
||
136 | * |
||
137 | * @param Role $role |
||
138 | * |
||
139 | * @return GroupInterface |
||
140 | * |
||
141 | * @throws InvalidArgumentException |
||
142 | */ |
||
143 | 8 | public function addRole($role) |
|
155 | |||
156 | /** |
||
157 | * Pass a string, remove the Role object from collection. |
||
158 | * |
||
159 | * @param string $role |
||
160 | * |
||
161 | * @return GroupInterface |
||
162 | */ |
||
163 | 1 | public function removeRole($role) |
|
172 | |||
173 | /** |
||
174 | * Pass an ARRAY of Role objects and will clear the collection and re-set it with new Roles. |
||
175 | * |
||
176 | * @param Role[] $roles array of Role objects |
||
177 | * |
||
178 | * @return GroupInterface |
||
179 | */ |
||
180 | 1 | public function setRoles(array $roles) |
|
189 | |||
190 | /** |
||
191 | * Directly set the ArrayCollection of Roles. Type hinted as Collection which is the parent of (Array|Persistent)Collection. |
||
192 | * |
||
193 | * @param Collection $collection |
||
194 | * |
||
195 | * @return GroupInterface |
||
196 | */ |
||
197 | 1 | public function setRolesCollection(Collection $collection) |
|
203 | |||
204 | /** |
||
205 | * Return the name of the group |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | 2 | public function getName() |
|
213 | |||
214 | /** |
||
215 | * Set the name of the group |
||
216 | * |
||
217 | * @param string $name New name of the group |
||
218 | * |
||
219 | * @return GroupInterface |
||
220 | */ |
||
221 | 1 | public function setName($name) |
|
227 | |||
228 | /** |
||
229 | * @Assert\Callback |
||
230 | * |
||
231 | * @param ExecutionContextInterface $context |
||
232 | */ |
||
233 | 2 | public function isGroupValid(ExecutionContextInterface $context) |
|
242 | } |
||
243 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.