1 | <?php |
||
15 | class CalendarController extends JsonController |
||
16 | { |
||
17 | /** |
||
18 | * @Route("/schedule/events") |
||
19 | * @Method("GET") |
||
20 | * |
||
21 | * @return JsonResponse |
||
22 | */ |
||
23 | public function eventsListAction() |
||
24 | { |
||
25 | $result = $this->get('app.google_calendar') |
||
26 | ->getEventList(); |
||
27 | $response = ['events' => $result]; |
||
28 | |||
29 | return new JsonResponse($response); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @param Request $request |
||
34 | * @param User $user |
||
|
|||
35 | * @Route("/api/schedule/event/new/") |
||
36 | * @Method("POST") |
||
37 | * |
||
38 | * @return JsonResponse |
||
39 | */ |
||
40 | public function newEventAction(Request $request) |
||
41 | { |
||
42 | $dtoEvent = new DtoEvent(); |
||
43 | $form = $this->createForm(EventType::class, $dtoEvent); |
||
44 | $this->handleJsonForm($form, $request); |
||
45 | $result = $this->get('app.google_calendar') |
||
46 | ->createEvent($dtoEvent); |
||
47 | if (!$result) { |
||
48 | return $this->json(['error' => 'Event has not been created'], 412); |
||
49 | } |
||
50 | $user = $this->getUser(); |
||
51 | $em = $this->getDoctrine()->getManager(); |
||
52 | $event = new Event(); |
||
53 | $event->setGoogleId($result->id); |
||
54 | $event->setUsers($user); |
||
55 | $user->setEvent($event); |
||
56 | |||
57 | $em->persist($user); |
||
58 | $em->persist($event); |
||
59 | $em->flush(); |
||
60 | |||
61 | return $this->json(['success' => 'Event created'], 201); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param $id |
||
66 | * @Route("/schedule/event/{id}") |
||
67 | * @Method("GET") |
||
68 | * |
||
69 | * @return JsonResponse |
||
70 | */ |
||
71 | public function singleEventAction($id) |
||
72 | { |
||
73 | $event = $this->get('app.google_calendar') |
||
74 | ->getEventById($id); |
||
75 | if (!$event) { |
||
76 | return $this->json(['error' => 'Event not found'], 404); |
||
77 | } |
||
78 | |||
79 | return $this->json($event, 200); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param User $user |
||
84 | * @Route("/schedule/event/user/{id}") |
||
85 | * @Method("GET") |
||
86 | * |
||
87 | * @return JsonResponse |
||
88 | */ |
||
89 | public function usersEventAction(User $user) |
||
90 | { |
||
91 | $events = $user->getEvents(); |
||
92 | |||
93 | $googleEvents = []; |
||
94 | |||
95 | $calendar = $this->get('app.google_calendar'); |
||
96 | foreach ($events as $event) { |
||
97 | $googleEvents[] = $calendar |
||
98 | ->getEventById($event->getGoogleId()); |
||
99 | } |
||
100 | if (!$googleEvents) { |
||
101 | return $this->json(['error' => 'Events not found'], 404); |
||
102 | } |
||
103 | |||
104 | $response = ['events' => $googleEvents]; |
||
105 | |||
106 | return new JsonResponse($response); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @param $id |
||
111 | * @Route("/schedule/event/remove/{id}") |
||
112 | * |
||
113 | * @return JsonResponse |
||
114 | */ |
||
115 | public function removeEventAction($id) |
||
122 | |||
123 | /** |
||
124 | * @param Request $request |
||
125 | * @param $id |
||
126 | * @Route("/schedule/event/edit/{id}") |
||
127 | * |
||
128 | * @return JsonResponse |
||
129 | */ |
||
130 | public function editEventAction(Request $request, $id) |
||
138 | |||
139 | /** |
||
140 | * FOR DEV ONLY. |
||
141 | * |
||
142 | * @Route("/schedule/clear") |
||
143 | */ |
||
144 | public function clearAction() |
||
150 | } |
||
151 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.