Conversation
| return new JsonResponse(['status' => 'ok']); | ||
| } | ||
|
|
||
| public function list() |
There was a problem hiding this comment.
let's keep index() is more semantical in terms on REST APIs
| public function list() | |
| public function index() |
| @@ -65,20 +56,21 @@ public function new(Request $request) | |||
| $clinic = new Clinic(); | |||
There was a problem hiding this comment.
Please, continue using forms
| return new JsonResponse(['msg' => 'Clinic not found!'], Response::HTTP_NOT_FOUND); | ||
| } | ||
|
|
||
| $address = $clinic->getAddress(); |
There was a problem hiding this comment.
Avoid to do that, please continue using forms
| $entityManager->flush(); | ||
|
|
||
| $response = new Response('Pet created whit success!', Response::HTTP_CREATED); | ||
| $response->headers->set('Location', '/some/programmer/url'); |
| if (empty($pet)) { | ||
| return new JsonResponse(['msg' => 'Pet not found!'], Response::HTTP_NOT_FOUND); | ||
| } | ||
| // reference: https://symfonycasts.com/screencast/symfony-rest/form-post |
There was a problem hiding this comment.
Please remove this comment
| if (!empty($pet->getPetName())) { | ||
| $entityManager = $this->getDoctrine()->getManager(); | ||
| $entityManager->flush(); | ||
| $pet = new Pet(); |
There was a problem hiding this comment.
This doesn't make sense. Why are you instantiating a new Pet object here?
|
|
||
| return new JsonResponse(['msg' => 'Check the empty fields'], Response::HTTP_NOT_ACCEPTABLE); | ||
| $response = new Response('Pet edited whit success!', Response::HTTP_OK); | ||
| $response->headers->set('Location', '/some/programmer/url'); |
There was a problem hiding this comment.
On line 80: In a video lesson, is done a recommendation for send an URL where consumer can view the entered data, but i forgot of alter. Should i keep, fix or remove?
There was a problem hiding this comment.
For now, could you please remove?
| return new JsonResponse(['msg' => 'We could not find'], Response::HTTP_NOT_ACCEPTABLE); | ||
| $response = new JsonResponse(['msg'=>'Clinic deleted whit success!'], Response::HTTP_OK); | ||
|
|
||
| return $response; |
There was a problem hiding this comment.
This return $response is unnecessary. You can just return the new JsonResponse object, like this:
| return $response; | |
| return new JsonResponse(['msg' => 'We could not find'], Response::HTTP_OK); |
In this PR i applied the best practices, following recommendations from issue #3