@@ 148-174 (lines=27) @@ | ||
145 | * @param UUID $breweryId Brewery Id |
|
146 | * @param UUID $beerId Beer Id |
|
147 | */ |
|
148 | public function putAction($breweryId, Request $request, $beerId) |
|
149 | { |
|
150 | $beer = $this->getDoctrine()->getManager() |
|
151 | ->getRepository('MaxpouBeerBundle:Beer') |
|
152 | ->find($beerId); |
|
153 | ||
154 | if (!$beer) { |
|
155 | throw new HttpException(404, 'Unable to find this Beer entity'); |
|
156 | } |
|
157 | ||
158 | $form = $this->createForm(BeerApiType::class, $beer); |
|
159 | $form->submit($request->request->all()); |
|
160 | ||
161 | if ($form->isValid()) { |
|
162 | $em = $this->getDoctrine()->getManager(); |
|
163 | $em->persist($beer); |
|
164 | $em->flush(); |
|
165 | ||
166 | $view = $this->view(null, 204); |
|
167 | ||
168 | return $this->handleView($view); |
|
169 | } else { |
|
170 | $view = $this->view($form, 400); |
|
171 | } |
|
172 | ||
173 | return $view; |
|
174 | } |
|
175 | ||
176 | /** |
|
177 | * Delete brewery. |
@@ 140-166 (lines=27) @@ | ||
137 | * |
|
138 | * @param UUID $breweryId Brewery Id |
|
139 | */ |
|
140 | public function putAction(Request $request, $breweryId) |
|
141 | { |
|
142 | $brewery = $this->getDoctrine()->getManager() |
|
143 | ->getRepository('MaxpouBeerBundle:Brewery') |
|
144 | ->find($breweryId); |
|
145 | ||
146 | if (!$brewery) { |
|
147 | throw new HttpException(404, 'Unable to find this Brewery entity'); |
|
148 | } |
|
149 | ||
150 | $form = $this->createForm(BreweryType::class, $brewery); |
|
151 | $form->submit($request->request->all()); |
|
152 | ||
153 | if ($form->isValid()) { |
|
154 | $em = $this->getDoctrine()->getManager(); |
|
155 | $em->persist($brewery); |
|
156 | $em->flush(); |
|
157 | ||
158 | $view = $this->view(null, 204); |
|
159 | ||
160 | return $this->handleView($view); |
|
161 | } else { |
|
162 | $view = $this->view($form, 400); |
|
163 | } |
|
164 | ||
165 | return $view; |
|
166 | } |
|
167 | ||
168 | /** |
|
169 | * Delete brewery. |