1 | <?php |
||
34 | class MovieController extends BaseController |
||
35 | { |
||
36 | /** |
||
37 | * Get all movies. |
||
38 | * |
||
39 | * @Route("/api/movies", methods={"GET"}) |
||
40 | * |
||
41 | * @param Request $request |
||
42 | * @param MovieRepository $movieRepository |
||
43 | * |
||
44 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
45 | */ |
||
46 | 17 | public function getAll(Request $request, MovieRepository $movieRepository) |
|
57 | |||
58 | /** |
||
59 | * Get movie resource. |
||
60 | * |
||
61 | * @Route("/api/movies/{id}", methods={"GET"}, requirements={"id"="\d+"}) |
||
62 | * |
||
63 | * @param int $id |
||
64 | * @param MovieRepository $repository |
||
65 | * @param ProducerInterface $producer |
||
66 | * |
||
67 | * @throws \Doctrine\ORM\NoResultException |
||
68 | * @throws \Doctrine\ORM\NonUniqueResultException |
||
69 | * |
||
70 | * @return JsonResponse |
||
71 | */ |
||
72 | 2 | public function getMovies(int $id, MovieRepository $repository, ProducerInterface $producer) |
|
73 | { |
||
74 | 2 | if (null === $movie = $repository->findOneForMoviePage($id, $this->getUser())) { |
|
75 | throw new NotFoundHttpException(); |
||
76 | } |
||
77 | |||
78 | 2 | if (\count($movie->getSimilarMovies()) === 0) { |
|
79 | 2 | $producer->sendEvent(SimilarMoviesProcessor::LOAD_SIMILAR_MOVIES, json_encode($movie->getId())); |
|
80 | } |
||
81 | |||
82 | return $this->response($movie, 200, [], [ |
||
83 | 'groups' => ['view'], |
||
84 | ]); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @Route("/api/movies/{movieId}/releaseDate/{countryCode}", methods={"GET"}, requirements={"movieId"="\d+"}) |
||
89 | * @ParamConverter("country", options={"mapping": {"countryCode": "code"}}) |
||
90 | */ |
||
91 | public function getMovieReleaseDate(int $movieId, Country $country, MovieReleaseDateRepository $repository) |
||
101 | |||
102 | /** |
||
103 | * @Route("/api/movies/{id}/updatePoster", methods={"POST"}, requirements={"id"="\d+"}) |
||
104 | * |
||
105 | * @param Movie $movie |
||
106 | * @param UpdatePosterRequest $request |
||
107 | * |
||
108 | * @return JsonResponse |
||
109 | */ |
||
110 | 1 | public function postMoviesUpdatePoster(Movie $movie, UpdatePosterRequest $request) |
|
123 | |||
124 | /** |
||
125 | * Get movies by title. |
||
126 | * |
||
127 | * @Route("/api/movies/search", methods={"POST"}) |
||
128 | * |
||
129 | * @param SearchRequest $request |
||
130 | * @param SearchService $searchService |
||
131 | * @param Request $currentRequest |
||
132 | * |
||
133 | * @throws \Exception |
||
134 | * |
||
135 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
136 | */ |
||
137 | 2 | public function getSearch(SearchRequest $request, SearchService $searchService, Request $currentRequest) |
|
149 | |||
150 | /** |
||
151 | * Create new movie. |
||
152 | * |
||
153 | * @Route("/api/movies", methods={"POST"}) |
||
154 | * |
||
155 | * @param CreateMovieRequest $request |
||
156 | * @param MovieManageService $service |
||
157 | * @param ValidatorInterface $validator |
||
158 | * |
||
159 | * @throws \Exception |
||
160 | * |
||
161 | * @return \Symfony\Component\HttpFoundation\JsonResponse |
||
162 | */ |
||
163 | 2 | public function postMovies(CreateMovieRequest $request, MovieManageService $service, ValidatorInterface $validator) |
|
182 | |||
183 | /** |
||
184 | * @Route("/api/movies/{id}", methods={"POST", "PUT", "PATCH"}, requirements={"id"="\d+"}) |
||
185 | * |
||
186 | * @param Movie $movie |
||
187 | * @param UpdateMovieRequest $request |
||
188 | * |
||
189 | * @throws \ErrorException |
||
190 | * @throws \Exception |
||
191 | * |
||
192 | * @return JsonResponse |
||
193 | */ |
||
194 | 2 | public function putMovies(Movie $movie, UpdateMovieRequest $request) |
|
227 | } |
||
228 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.