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