@@ 90-102 (lines=13) @@ | ||
87 | /** |
|
88 | * @param string|int $id |
|
89 | */ |
|
90 | protected function viewEntity(AbstractRepository $repository, $id): Response |
|
91 | { |
|
92 | $entity = $repository->findOneById($id); |
|
93 | $entityClass = $repository->getClassName(); |
|
94 | ||
95 | if ($entity) { |
|
96 | $response = new ApiResponse($entity, Response::HTTP_OK); |
|
97 | } else { |
|
98 | $response = $this->createEntityNotFoundResponse($entityClass, $id); |
|
99 | } |
|
100 | ||
101 | return $this->respond($response); |
|
102 | } |
|
103 | ||
104 | private function setLocation(Response $response, AbstractApiResponse $apiResponse) |
|
105 | { |
@@ 175-187 (lines=13) @@ | ||
172 | * } |
|
173 | * ) |
|
174 | */ |
|
175 | public function listMembersAction(string $bandName): Response |
|
176 | { |
|
177 | $bandRepository = $this->get('rockparade.band_repository'); |
|
178 | $band = $bandRepository->findOneByName($bandName); |
|
179 | ||
180 | if (!$band) { |
|
181 | $response = $this->createEntityNotFoundResponse(Band::class, $bandName); |
|
182 | } else { |
|
183 | $response = new ApiResponse($band->getMembers(), Response::HTTP_OK); |
|
184 | } |
|
185 | ||
186 | return $this->respond($response); |
|
187 | } |
|
188 | ||
189 | /** |
|
190 | * Add member to band |