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