Skip to content

Conversation

@micaelmf
Copy link
Owner

In this PR i applied the best practices, following recommendations from issue #3

@micaelmf micaelmf requested a review from Luitame August 22, 2019 16:45
return new JsonResponse(['status' => 'ok']);
}

public function list()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep index() is more semantical in terms on REST APIs

Suggested change
public function list()
public function index()

$address->setNumber($request->get('number'));
$address->setCity($request->get('city'));

$clinic = new Clinic();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, continue using forms

return new JsonResponse(['msg' => 'Clinic not found!'], Response::HTTP_NOT_FOUND);
}

$address = $clinic->getAddress();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's that?

if (empty($pet)) {
return new JsonResponse(['msg' => 'Pet not found!'], Response::HTTP_NOT_FOUND);
}
// reference: https://symfonycasts.com/screencast/symfony-rest/form-post
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comment

if (!empty($pet->getPetName())) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->flush();
$pet = new Pet();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/some/programmer/url?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return $response is unnecessary. You can just return the new JsonResponse object, like this:

Suggested change
return $response;
return new JsonResponse(['msg' => 'We could not find'], Response::HTTP_OK);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants