| @@ 177-189 (lines=13) @@ | ||
| 174 | * } |
|
| 175 | * ) |
|
| 176 | */ |
|
| 177 | public function listMembersAction(string $bandName): Response |
|
| 178 | { |
|
| 179 | $bandRepository = $this->get('rockparade.band_repository'); |
|
| 180 | $band = $bandRepository->findOneByName($bandName); |
|
| 181 | ||
| 182 | if (!$band) { |
|
| 183 | $response = $this->createEntityNotFoundResponse(Band::class, $bandName); |
|
| 184 | } else { |
|
| 185 | $response = new ApiResponse($band->getMembers(), Response::HTTP_OK); |
|
| 186 | } |
|
| 187 | ||
| 188 | return $this->respond($response); |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| 192 | * Add member to band |
|
| @@ 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 | { |
|