/** * @Route("/note/{id}", name="note_update") * @Method("PUT") */ public function updateAction(Request $request, Note $note) { $payload = json_decode($request->getContent(), true); $note->setTitle($payload['title']); $note->setContent($payload['content']); $note->setSize($payload['size']); /** @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); $em->persist($note); $em->flush(); $noteNormalized = $this->get('serializer')->normalize($note); return new JsonResponse($noteNormalized); }