1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace KI\UserBundle\Controller; |
4
|
|
|
|
5
|
|
|
use KI\CoreBundle\Controller\SubresourceController; |
6
|
|
|
use KI\UserBundle\Entity\ClubUser; |
7
|
|
|
use KI\UserBundle\Form\ClubUserType; |
8
|
|
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc; |
9
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; |
10
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
13
|
|
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
14
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
15
|
|
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException; |
16
|
|
|
|
17
|
|
|
class ClubsController extends SubresourceController |
18
|
|
|
{ |
19
|
|
|
public function setContainer(ContainerInterface $container = null) |
20
|
|
|
{ |
21
|
|
|
parent::setContainer($container); |
22
|
|
|
$this->initialize('Club', 'User'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @ApiDoc( |
27
|
|
|
* resource=true, |
28
|
|
|
* description="Liste les clubs", |
29
|
|
|
* output="KI\UserBundle\Entity\Club", |
30
|
|
|
* statusCodes={ |
31
|
|
|
* 200="Requête traitée avec succès", |
32
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
33
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
34
|
|
|
* }, |
35
|
|
|
* section="Utilisateurs" |
36
|
|
|
* ) |
37
|
|
|
* @Route("/clubs") |
38
|
|
|
* @Method("GET") |
39
|
|
|
*/ |
40
|
|
|
public function getClubsAction() |
41
|
|
|
{ |
42
|
|
|
return $this->getAll($this->is('EXTERIEUR')); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @ApiDoc( |
47
|
|
|
* description="Retourne un club", |
48
|
|
|
* output="KI\UserBundle\Entity\Club", |
49
|
|
|
* statusCodes={ |
50
|
|
|
* 200="Requête traitée avec succès", |
51
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
52
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
53
|
|
|
* 404="Ressource non trouvée" |
54
|
|
|
* }, |
55
|
|
|
* section="Utilisateurs" |
56
|
|
|
* ) |
57
|
|
|
* @Route("/clubs/{slug}") |
58
|
|
|
* @Method("GET") |
59
|
|
|
*/ |
60
|
|
|
public function getClubAction($slug) |
61
|
|
|
{ |
62
|
|
|
$club = $this->getOne($slug, $this->is('EXTERIEUR')); |
63
|
|
|
|
64
|
|
|
return $this->json($club); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ApiDoc( |
69
|
|
|
* description="Crée un club", |
70
|
|
|
* input="KI\UserBundle\Form\ClubType", |
71
|
|
|
* output="KI\UserBundle\Entity\Club", |
72
|
|
|
* statusCodes={ |
73
|
|
|
* 201="Requête traitée avec succès avec création d’un document", |
74
|
|
|
* 400="La syntaxe de la requête est erronée", |
75
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
76
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
77
|
|
|
* }, |
78
|
|
|
* section="Utilisateurs" |
79
|
|
|
* ) |
80
|
|
|
* @Route("/clubs") |
81
|
|
|
* @Method("POST") |
82
|
|
|
*/ |
83
|
|
|
public function postClubAction() |
84
|
|
|
{ |
85
|
|
|
$data = $this->post(); |
86
|
|
|
|
87
|
|
|
return $this->formJson($data); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @ApiDoc( |
92
|
|
|
* description="Modifie un club", |
93
|
|
|
* input="KI\UserBundle\Form\ClubType", |
94
|
|
|
* statusCodes={ |
95
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
96
|
|
|
* 400="La syntaxe de la requête est erronée", |
97
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
98
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
99
|
|
|
* 404="Ressource non trouvée", |
100
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
101
|
|
|
* }, |
102
|
|
|
* section="Utilisateurs" |
103
|
|
|
* ) |
104
|
|
|
* @Route("/clubs/{slug}") |
105
|
|
|
* @Method("PATCH") |
106
|
|
|
*/ |
107
|
|
|
public function patchClubAction($slug) |
108
|
|
|
{ |
109
|
|
|
$data = $this->patch( |
110
|
|
|
$slug, |
111
|
|
|
$this->isClubMember($slug) |
112
|
|
|
&& (!$this->get('security.authorization_checker')->isGranted('ROLE_EXTERIEUR') |
113
|
|
|
|| $slug == $this->user->getSlug() |
114
|
|
|
) |
115
|
|
|
); |
116
|
|
|
|
117
|
|
|
return $this->formJson($data); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @ApiDoc( |
122
|
|
|
* description="Supprime un club", |
123
|
|
|
* statusCodes={ |
124
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
125
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
126
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
127
|
|
|
* 404="Ressource non trouvée", |
128
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
129
|
|
|
* }, |
130
|
|
|
* section="Utilisateurs" |
131
|
|
|
* ) |
132
|
|
|
* @Route("/clubs/{slug}") |
133
|
|
|
* @Method("DELETE") |
134
|
|
|
*/ |
135
|
|
View Code Duplication |
public function deleteClubAction($slug) |
136
|
|
|
{ |
137
|
|
|
$repoLink = $this->manager->getRepository('KIUserBundle:ClubUser'); |
138
|
|
|
$club = $this->findBySlug($slug); |
139
|
|
|
$link = $repoLink->findBy(['club' => $club]); |
140
|
|
|
|
141
|
|
|
foreach ($link as $clubUser) { |
142
|
|
|
$this->manager->remove($clubUser); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
$this->delete($slug); |
146
|
|
|
|
147
|
|
|
return $this->json(null, 204); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @ApiDoc( |
152
|
|
|
* description="Liste les membres d'un club", |
153
|
|
|
* output="KI\UserBundle\Entity\User", |
154
|
|
|
* statusCodes={ |
155
|
|
|
* 200="Requête traitée avec succès", |
156
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
157
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
158
|
|
|
* 404="Ressource non trouvée", |
159
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
160
|
|
|
* }, |
161
|
|
|
* section="Utilisateurs" |
162
|
|
|
* ) |
163
|
|
|
* @Route("/clubs/{slug}/users") |
164
|
|
|
* @Method("GET") |
165
|
|
|
*/ |
166
|
|
|
public function getClubUsersAction($slug) |
167
|
|
|
{ |
168
|
|
|
$members = $this->getAllSub($slug, 'User', false); |
169
|
|
|
|
170
|
|
|
return $this->json($members); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @ApiDoc( |
175
|
|
|
* description="Ajoute un membre à un club", |
176
|
|
|
* requirements={ |
177
|
|
|
* { |
178
|
|
|
* "name"="role", |
179
|
|
|
* "dataType"="string", |
180
|
|
|
* "description"="Le rôle du membre dans le club" |
181
|
|
|
* } |
182
|
|
|
* }, |
183
|
|
|
* statusCodes={ |
184
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
185
|
|
|
* 400="La syntaxe de la requête est erronée", |
186
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
187
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
188
|
|
|
* 404="Ressource non trouvée", |
189
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
190
|
|
|
* }, |
191
|
|
|
* section="Utilisateurs" |
192
|
|
|
* ) |
193
|
|
|
* @Route("/clubs/{slugClub}/users/{username}") |
194
|
|
|
* @Method("POST") |
195
|
|
|
*/ |
196
|
|
|
public function postClubUserAction(Request $request, $slugClub, $username) |
197
|
|
|
{ |
198
|
|
|
$this->trust($this->is('ADMIN') || $this->isClubMember($slugClub)); |
199
|
|
|
|
200
|
|
|
// On récupère les deux entités concernées |
201
|
|
|
$userRepository = $this->manager->getRepository('KIUserBundle:User'); |
202
|
|
|
$user = $userRepository->findOneByUsername($username); |
203
|
|
|
$club = $this->findBySlug($slugClub); |
204
|
|
|
|
205
|
|
|
// Vérifie que la relation n'existe pas déjà |
206
|
|
|
$repoLink = $this->manager->getRepository('KIUserBundle:ClubUser'); |
207
|
|
|
$link = $repoLink->findBy(['club' => $club, 'user' => $user]); |
208
|
|
|
|
209
|
|
|
// On crée la relation si elle n'existe pas déjà |
210
|
|
|
if (count($link) == 0) { |
211
|
|
|
// Création de l'entité relation |
212
|
|
|
$link = new ClubUser(); |
213
|
|
|
$link->setClub($club); |
214
|
|
|
$link->setUser($user); |
215
|
|
|
$link->setPriority($user->getId()); |
216
|
|
|
|
217
|
|
|
// Validation des données annexes |
218
|
|
|
$form = $this->createForm(ClubUserType::class, $link, ['method' => 'POST']); |
219
|
|
|
$form->handleRequest($request); |
220
|
|
|
|
221
|
|
View Code Duplication |
if ($form->isValid()) { |
222
|
|
|
$this->manager->persist($link); |
223
|
|
|
$this->manager->flush(); |
224
|
|
|
|
225
|
|
|
return $this->json(null, 204); |
226
|
|
|
} else { |
227
|
|
|
$this->manager->detach($link); |
228
|
|
|
return $this->json($form, 400); |
229
|
|
|
} |
230
|
|
|
} else |
231
|
|
|
throw new BadRequestHttpException('La relation entre Club et User existe déjà'); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @ApiDoc( |
236
|
|
|
* description="Modifie un membre d'un club", |
237
|
|
|
* requirements={ |
238
|
|
|
* { |
239
|
|
|
* "name"="role", |
240
|
|
|
* "dataType"="string", |
241
|
|
|
* "description"="Le rôle du membre dans le club" |
242
|
|
|
* } |
243
|
|
|
* }, |
244
|
|
|
* statusCodes={ |
245
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
246
|
|
|
* 400="La syntaxe de la requête est erronée", |
247
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
248
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
249
|
|
|
* 404="Ressource non trouvée", |
250
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
251
|
|
|
* }, |
252
|
|
|
* section="Utilisateurs" |
253
|
|
|
* ) |
254
|
|
|
* @Route("/clubs/{slug}/users/{username}") |
255
|
|
|
* @Method("PATCH") |
256
|
|
|
*/ |
257
|
|
|
public function patchClubUserAction(Request $request, $slug, $username) |
258
|
|
|
{ |
259
|
|
|
$this->trust($this->is('ADMIN') || $this->isClubMember($slug)); |
260
|
|
|
|
261
|
|
|
// On récupère les deux entités concernées |
262
|
|
|
$repo = $this->manager->getRepository('KIUserBundle:User'); |
263
|
|
|
$user = $repo->findOneByUsername($username); |
264
|
|
|
$club = $this->findBySlug($slug); |
265
|
|
|
|
266
|
|
|
// Vérifie que la relation n'existe pas déjà |
267
|
|
|
$repoLink = $this->manager->getRepository('KIUserBundle:ClubUser'); |
268
|
|
|
$link = $repoLink->findBy(['club' => $club, 'user' => $user]); |
269
|
|
|
|
270
|
|
|
// On édite la relation si elle existe (de façon unique) |
271
|
|
|
if (count($link) == 1) { |
272
|
|
|
$link = $link[0]; |
273
|
|
|
// Validation des données annexes |
274
|
|
|
$form = $this->createForm(ClubUserType::class, $link, ['method' => 'PATCH']); |
275
|
|
|
$form->handleRequest($request); |
276
|
|
|
|
277
|
|
View Code Duplication |
if ($form->isValid()) { |
278
|
|
|
$this->manager->persist($link); |
279
|
|
|
$this->manager->flush(); |
280
|
|
|
|
281
|
|
|
return $this->json(null, 204); |
282
|
|
|
} else { |
283
|
|
|
$this->manager->detach($link); |
284
|
|
|
return $this->json($form, 400); |
285
|
|
|
} |
286
|
|
|
} else |
287
|
|
|
throw new BadRequestHttpException('Cette personne ne fait pas partie du club !'); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* @ApiDoc( |
292
|
|
|
* description="Enlève un membre d'un club", |
293
|
|
|
* statusCodes={ |
294
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
295
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
296
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
297
|
|
|
* 404="Ressource non trouvée", |
298
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
299
|
|
|
* }, |
300
|
|
|
* section="Utilisateurs" |
301
|
|
|
* ) |
302
|
|
|
* @Route("/clubs/{slug}/users/{id}") |
303
|
|
|
* @Method("DELETE") |
304
|
|
|
*/ |
305
|
|
|
public function deleteClubUserAction($slug, $id) |
306
|
|
|
{ |
307
|
|
|
if (!($this->is('ADMIN') || $this->isClubMember($slug))) |
308
|
|
|
throw new AccessDeniedException('Accès refusé'); |
309
|
|
|
|
310
|
|
|
// On récupère les deux entités concernées |
311
|
|
|
$repo = $this->manager->getRepository('KIUserBundle:User'); |
312
|
|
|
$user = $repo->findOneByUsername($id); |
313
|
|
|
$club = $this->findBySlug($slug); |
314
|
|
|
|
315
|
|
|
// On récupère la relation |
316
|
|
|
$repoLink = $this->manager->getRepository('KIUserBundle:ClubUser'); |
317
|
|
|
$link = $repoLink->findBy(['club' => $club, 'user' => $user]); |
318
|
|
|
|
319
|
|
|
// Supprime la relation si elle existe |
320
|
|
|
if (count($link) == 1) { |
321
|
|
|
$this->manager->remove($link[0]); |
322
|
|
|
$this->manager->flush(); |
323
|
|
|
} else |
324
|
|
|
throw new NotFoundHttpException('Relation entre Club et User non trouvée'); |
325
|
|
|
return $this->json(null, 204); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @ApiDoc( |
330
|
|
|
* description="Echange les priorité des 2 clubUsers associés aux Users", |
331
|
|
|
* statusCodes={ |
332
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
333
|
|
|
* 400="La syntaxe de la requête est erronée", |
334
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
335
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
336
|
|
|
* 404="Ressource non trouvée", |
337
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
338
|
|
|
* }, |
339
|
|
|
* section="Utilisateurs" |
340
|
|
|
* ) |
341
|
|
|
* @Route("/clubs/{slug}/users/{username}/{direction}") |
342
|
|
|
* @Method("PATCH") |
343
|
|
|
*/ |
344
|
|
|
public function swapPriorityClubUserAction($slug, $username, $direction) |
345
|
|
|
{ |
346
|
|
|
$this->trust($this->is('ADMIN') || $this->isClubMember($slug)); |
347
|
|
|
|
348
|
|
|
// On récupère les entités concernées |
349
|
|
|
$repo = $this->manager->getRepository('KIUserBundle:User'); |
350
|
|
|
$user = $repo->findOneByUsername($username); |
351
|
|
|
$club = $this->findBySlug($slug); |
352
|
|
|
|
353
|
|
|
// Trouve les clubUsers assiciés aux Users |
354
|
|
|
$clubUserRepository = $this->manager->getRepository('KIUserBundle:ClubUser'); |
355
|
|
|
$clubUser = $clubUserRepository->findOneBy(['club' => $club, 'user' => $user]); |
356
|
|
|
|
357
|
|
|
$priority = $clubUser->getPriority(); |
358
|
|
|
$promo = $user->getPromo(); |
359
|
|
|
|
360
|
|
|
if ($direction == 'down') { |
361
|
|
|
$swappedWith = $clubUserRepository->getUserBelowInClubWithPromo($club, $promo, $priority); |
362
|
|
|
} else if ($direction == 'up') { |
363
|
|
|
$swappedWith = $clubUserRepository->getUserAboveInClubWithPromo($club, $promo, $priority); |
364
|
|
|
} else |
365
|
|
|
throw new BadRequestHttpException('Direction invalide'); |
366
|
|
|
|
367
|
|
|
$clubUser->setPriority($swappedWith->getPriority()); |
368
|
|
|
$swappedWith->setPriority($priority); |
369
|
|
|
$this->manager->flush(); |
370
|
|
|
|
371
|
|
|
return $this->json(null, 204); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* @ApiDoc( |
376
|
|
|
* description="Abonne un utilisateur à un club", |
377
|
|
|
* statusCodes={ |
378
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
379
|
|
|
* 400="La syntaxe de la requête est erronée", |
380
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
381
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
382
|
|
|
* 404="Ressource non trouvée", |
383
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
384
|
|
|
* }, |
385
|
|
|
* section="Utilisateurs" |
386
|
|
|
* ) |
387
|
|
|
* @Route("/clubs/{slug}/follow") |
388
|
|
|
* @Method("POST") |
389
|
|
|
*/ |
390
|
|
View Code Duplication |
public function followClubAction($slug) |
391
|
|
|
{ |
392
|
|
|
$user = $this->user; |
393
|
|
|
$club = $this->findBySlug($slug); |
394
|
|
|
|
395
|
|
|
if (!$user->getClubsNotFollowed()->contains($club)) { |
396
|
|
|
throw new BadRequestHttpException('Vous êtes déjà abonné à ce club'); |
397
|
|
|
} else { |
398
|
|
|
$user->removeClubNotFollowed($club); |
399
|
|
|
$this->manager->flush(); |
400
|
|
|
|
401
|
|
|
return $this->json(null, 204); |
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* @ApiDoc( |
407
|
|
|
* description="Désabonne un utilisateur d'un club", |
408
|
|
|
* statusCodes={ |
409
|
|
|
* 204="Requête traitée avec succès mais pas d’information à renvoyer", |
410
|
|
|
* 400="La syntaxe de la requête est erronée", |
411
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
412
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
413
|
|
|
* 404="Ressource non trouvée", |
414
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
415
|
|
|
* }, |
416
|
|
|
* section="Utilisateurs" |
417
|
|
|
* ) |
418
|
|
|
* @Route("/clubs/{slug}/unfollow") |
419
|
|
|
* @Method("POST") |
420
|
|
|
*/ |
421
|
|
View Code Duplication |
public function unFollowClubAction($slug) |
422
|
|
|
{ |
423
|
|
|
$user = $this->user; |
424
|
|
|
$club = $this->findBySlug($slug); |
425
|
|
|
|
426
|
|
|
if ($user->getClubsNotFollowed()->contains($club)) { |
427
|
|
|
throw new BadRequestHttpException('Vous n\'êtes pas abonné à ce club'); |
428
|
|
|
} else { |
429
|
|
|
$user->addClubNotFollowed($club); |
430
|
|
|
$this->manager->flush(); |
431
|
|
|
|
432
|
|
|
return $this->json(null, 204); |
433
|
|
|
} |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* @ApiDoc( |
438
|
|
|
* description="Retourne toutes les news publiées par un club", |
439
|
|
|
* statusCodes={ |
440
|
|
|
* 200="Requête traitée avec succès", |
441
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
442
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
443
|
|
|
* 404="Ressource non trouvée", |
444
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
445
|
|
|
* }, |
446
|
|
|
* section="Utilisateurs" |
447
|
|
|
* ) |
448
|
|
|
* @Route("/clubs/{slug}/newsitems") |
449
|
|
|
* @Method("GET") |
450
|
|
|
*/ |
451
|
|
View Code Duplication |
public function getNewsitemsClubAction($slug) |
452
|
|
|
{ |
453
|
|
|
$repository = $this->manager->getRepository('KIPublicationBundle:Newsitem'); |
454
|
|
|
|
455
|
|
|
$paginateHelper = $this->get('ki_core.helper.paginate'); |
456
|
|
|
extract($paginateHelper->paginateData($repository)); |
457
|
|
|
|
458
|
|
|
$findBy['authorClub'] = $this->findBySlug($slug); |
459
|
|
|
$results = $repository->findBy($findBy, $sortBy, $limit, $offset); |
460
|
|
|
list($results, $links, $count) = $paginateHelper->paginateView($results, $limit, $page, $totalPages, $count); |
461
|
|
|
|
462
|
|
|
return $this->json($results, 200, [ |
463
|
|
|
'Links' => implode(',', $links), |
464
|
|
|
'Total-count' => $count |
465
|
|
|
]); |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
/** |
469
|
|
|
* @ApiDoc( |
470
|
|
|
* description="Retourne tous les events publiés par un club", |
471
|
|
|
* statusCodes={ |
472
|
|
|
* 200="Requête traitée avec succès", |
473
|
|
|
* 401="Une authentification est nécessaire pour effectuer cette action", |
474
|
|
|
* 403="Pas les droits suffisants pour effectuer cette action", |
475
|
|
|
* 404="Ressource non trouvée", |
476
|
|
|
* 503="Service temporairement indisponible ou en maintenance", |
477
|
|
|
* }, |
478
|
|
|
* section="Utilisateurs" |
479
|
|
|
* ) |
480
|
|
|
* @Route("/clubs/{slug}/events") |
481
|
|
|
* @Method("GET") |
482
|
|
|
*/ |
483
|
|
View Code Duplication |
public function getEventsClubAction($slug) |
484
|
|
|
{ |
485
|
|
|
$repository = $this->manager->getRepository('KIPublicationBundle:Event'); |
486
|
|
|
|
487
|
|
|
$paginateHelper = $this->get('ki_core.helper.paginate'); |
488
|
|
|
extract($paginateHelper->paginateData($repository)); |
489
|
|
|
|
490
|
|
|
$findBy['authorClub'] = $this->findBySlug($slug); |
491
|
|
|
$results = $repository->findBy($findBy, $sortBy, $limit, $offset); |
492
|
|
|
list($results, $links, $count) = $paginateHelper->paginateView($results, $limit, $page, $totalPages, $count); |
493
|
|
|
|
494
|
|
|
return $this->json($results, 200, [ |
495
|
|
|
'Links' => implode(',', $links), |
496
|
|
|
'Total-count' => $count |
497
|
|
|
]); |
498
|
|
|
} |
499
|
|
|
} |
500
|
|
|
|