| @@ 183-195 (lines=13) @@ | ||
| 180 | * } |
|
| 181 | * ) |
|
| 182 | */ |
|
| 183 | public function listMembersAction(string $bandName): Response |
|
| 184 | { |
|
| 185 | $bandRepository = $this->get('rockparade.band_repository'); |
|
| 186 | $band = $bandRepository->findOneByName($bandName); |
|
| 187 | ||
| 188 | if (!$band) { |
|
| 189 | $response = $this->createEntityNotFoundResponse(Band::class, $bandName); |
|
| 190 | } else { |
|
| 191 | $response = new ApiResponse($band->getMembers(), Response::HTTP_OK); |
|
| 192 | } |
|
| 193 | ||
| 194 | return $this->respond($response); |
|
| 195 | } |
|
| 196 | ||
| 197 | /** |
|
| 198 | * Add member to band |
|
| @@ 104-116 (lines=13) @@ | ||
| 101 | /** |
|
| 102 | * @param string|int $id |
|
| 103 | */ |
|
| 104 | protected function viewEntity(AbstractRepository $repository, $id): Response |
|
| 105 | { |
|
| 106 | $entity = $repository->findOneById($id); |
|
| 107 | $entityClass = $repository->getClassName(); |
|
| 108 | ||
| 109 | if ($entity) { |
|
| 110 | $response = new ApiResponse($entity, Response::HTTP_OK); |
|
| 111 | } else { |
|
| 112 | $response = $this->createEntityNotFoundResponse($entityClass, $id); |
|
| 113 | } |
|
| 114 | ||
| 115 | return $this->respond($response); |
|
| 116 | } |
|
| 117 | ||
| 118 | private function setLocation(Response $response, AbstractApiResponse $apiResponse) |
|
| 119 | { |
|