1 | <?php |
||
24 | class TestGroupApiController extends Controller |
||
25 | { |
||
26 | private $_em; |
||
27 | |||
28 | 23 | public function setContainer(ContainerInterface $container = null) |
|
33 | |||
34 | /** |
||
35 | * Creates a new group |
||
36 | * |
||
37 | * @Route("") |
||
38 | * @Method({"POST"}) |
||
39 | * @Security("has_role('ROLE_SUPER_ADMIN')") |
||
40 | * @ApiDoc( |
||
41 | * resource=true, |
||
42 | * parameters={ |
||
43 | * {"name"="name", "description"="A user-friendly name for the group", "required"=true, "format"="Group 1", "dataType"="string"}, |
||
44 | * }, |
||
45 | * tags={ |
||
46 | * "Super Admin" = "#ff1919" |
||
47 | * } |
||
48 | * ) |
||
49 | */ |
||
50 | 2 | public function createGroupAction(Request $request) |
|
66 | |||
67 | /** |
||
68 | * Returns a list of all groups the current user has access to |
||
69 | * |
||
70 | * @Route("") |
||
71 | * @Method({"GET"}) |
||
72 | * @Security("has_role('ROLE_USER')") |
||
73 | * @ApiDoc( |
||
74 | * tags={ |
||
75 | * "Super Admin" = "#ff1919", |
||
76 | * "Admin" = "#ffff33", |
||
77 | * "User" = "#75ff47" |
||
78 | * } |
||
79 | * ) |
||
80 | */ |
||
81 | 2 | public function getAllGroupsAction() |
|
91 | |||
92 | /** |
||
93 | * Returns the details of the specified group |
||
94 | * |
||
95 | * @Route("/{id}") |
||
96 | * @Method({"GET"}) |
||
97 | * @Security("is_granted('view', group)") |
||
98 | * @ApiDoc( |
||
99 | * requirements={ |
||
100 | * {"name"="id", "description"="The ID of the group to return", "dataType"="integer", "requirement"="\d+"} |
||
101 | * }, |
||
102 | * tags={ |
||
103 | * "Super Admin" = "#ff1919", |
||
104 | * "Admin" = "#ffff33", |
||
105 | * "User" = "#75ff47" |
||
106 | * } |
||
107 | * ) |
||
108 | */ |
||
109 | 1 | public function getGroupAction(TestGroup $group) |
|
113 | |||
114 | /** |
||
115 | * Updates the given group |
||
116 | * |
||
117 | * @Route("/{id}") |
||
118 | * @Method({"PUT"}) |
||
119 | * @Security("has_role('ROLE_SUPER_ADMIN')") |
||
120 | * @ApiDoc( |
||
121 | * parameters={ |
||
122 | * {"name"="name", "description"="A user-friendly name for the group", "required"=false, "format"="Group 1", "dataType"="string"} |
||
123 | * }, |
||
124 | * requirements={ |
||
125 | * {"name"="id", "description"="The ID of the group to edit", "dataType"="integer", "requirement"="\d+"} |
||
126 | * }, |
||
127 | * tags={ |
||
128 | * "Super Admin" = "#ff1919" |
||
129 | * } |
||
130 | * ) |
||
131 | */ |
||
132 | 1 | public function updateGroupAction(Request $request, TestGroup $group) |
|
142 | |||
143 | /** |
||
144 | * Deletes the given group |
||
145 | * |
||
146 | * @Route("/{id}") |
||
147 | * @Method({"DELETE"}) |
||
148 | * @Security("has_role('ROLE_SUPER_ADMIN')") |
||
149 | * @ApiDoc( |
||
150 | * requirements={ |
||
151 | * {"name"="id", "description"="The ID of the group to delete", "dataType"="integer", "requirement"="\d+"} |
||
152 | * }, |
||
153 | * tags={ |
||
154 | * "Super Admin" = "#ff1919" |
||
155 | * } |
||
156 | * ) |
||
157 | */ |
||
158 | 2 | public function deleteGroupAction(TestGroup $group) |
|
169 | |||
170 | /** |
||
171 | * Adds the given user to the given group |
||
172 | * |
||
173 | * @Route("/{groupId}/user/{userId}") |
||
174 | * @Method({"POST"}) |
||
175 | * @Security("has_role('ROLE_SUPER_ADMIN')") |
||
176 | * @ParamConverter("group", class="OverwatchTestBundle:TestGroup", options={"id" = "groupId"}) |
||
177 | * @ParamConverter("user", class="OverwatchUserBundle:User", options={"id" = "userId"}) |
||
178 | * @ApiDoc( |
||
179 | * resource=true, |
||
180 | * requirements={ |
||
181 | * {"name"="userId", "description"="The ID of the user", "dataType"="integer", "requirement"="\d+"}, |
||
182 | * {"name"="groupId", "description"="The ID of the group", "dataType"="integer", "requirement"="\d+"} |
||
183 | * }, |
||
184 | * tags={ |
||
185 | * "Super Admin" = "#ff1919" |
||
186 | * } |
||
187 | * ) |
||
188 | */ |
||
189 | 1 | public function addUserToGroupAction(TestGroup $group, User $user) |
|
196 | |||
197 | /** |
||
198 | * Removes the given user from the given group |
||
199 | * |
||
200 | * @Route("/{groupId}/user/{userId}") |
||
201 | * @Method({"DELETE"}) |
||
202 | * @Security("has_role('ROLE_SUPER_ADMIN')") |
||
203 | * @ParamConverter("group", class="OverwatchTestBundle:TestGroup", options={"id" = "groupId"}) |
||
204 | * @ParamConverter("user", class="OverwatchUserBundle:User", options={"id" = "userId"}) |
||
205 | * @ApiDoc( |
||
206 | * requirements={ |
||
207 | * {"name"="userId", "description"="The ID of the user", "dataType"="integer", "requirement"="\d+"}, |
||
208 | * {"name"="groupId", "description"="The ID of the group", "dataType"="integer", "requirement"="\d+"} |
||
209 | * }, |
||
210 | * tags={ |
||
211 | * "Super Admin" = "#ff1919" |
||
212 | * } |
||
213 | * ) |
||
214 | */ |
||
215 | 1 | public function removeUserFromGroupAction(TestGroup $group, User $user) |
|
222 | } |
||
223 |