1 | <?php |
||
18 | class CalendarController extends JsonController |
||
19 | { |
||
20 | /** |
||
21 | * @Route("/") |
||
22 | * @Method("GET") |
||
23 | * |
||
24 | * @return JsonResponse |
||
25 | */ |
||
26 | public function eventsListAction(Request $request) |
||
31 | |||
32 | /** |
||
33 | * @param Request $request |
||
34 | * @Route("") |
||
35 | * @Method("POST") |
||
36 | * |
||
37 | * @return JsonResponse |
||
38 | */ |
||
39 | public function newEventAction(Request $request) |
||
66 | |||
67 | /** |
||
68 | * @param $id |
||
69 | * @Route("/{id}") |
||
70 | * @Method("GET") |
||
71 | * |
||
72 | * @return JsonResponse |
||
73 | */ |
||
74 | public function singleEventAction($id) |
||
75 | { |
||
76 | /** @var Event $event */ |
||
77 | $event = $this->getDoctrine()->getRepository('AppBundle:Event') |
||
78 | ->findByGoogleId($id); |
||
79 | $user = $event->getUsers()->first(); |
||
|
|||
80 | if (!$user) { |
||
81 | throw new JsonHttpException(404, 'User not found.'); |
||
82 | } |
||
83 | $googleEvent = $this->get('app.google_calendar') |
||
84 | ->getEventById($id); |
||
85 | if (!$googleEvent) { |
||
86 | throw new JsonHttpException(404, 'Event not found'); |
||
87 | } |
||
88 | $user = $this->get('serializer')->normalize($user, null, ['groups' => ['Short']]); |
||
89 | return new JsonResponse(['user' => $user, 'event' => $googleEvent]); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @Route("/user/{id}") |
||
94 | * @Method("GET") |
||
95 | * |
||
96 | * @return JsonResponse |
||
97 | */ |
||
98 | public function userEventsAction($id) |
||
119 | |||
120 | /** |
||
121 | * @param $id |
||
122 | * @Route("/{id}") |
||
123 | * @Method("DELETE") |
||
124 | * @return JsonResponse |
||
125 | */ |
||
126 | public function removeEventAction($id) |
||
138 | |||
139 | /** |
||
140 | * @param Request $request |
||
141 | * @Method("PATCH") |
||
142 | * @Route("/{id}") |
||
143 | * |
||
144 | * @return JsonResponse |
||
145 | */ |
||
146 | public function editEventAction(Request $request, $id) |
||
156 | |||
157 | /** |
||
158 | * FOR DEV ONLY. |
||
159 | * @Method("PUT") |
||
160 | * @Route("/clear") |
||
161 | */ |
||
162 | public function clearAction() |
||
168 | } |
||
169 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.