- $data = json_decode($request->getContent(), true);
-
- $em = $this->getDoctrine()->getManager();
-
- $annotation = new Annotation($this->getUser());
-
- $annotation->setText($data['text']);
- if (array_key_exists('quote', $data)) {
- $annotation->setQuote($data['quote']);
- }
- if (array_key_exists('ranges', $data)) {
- $annotation->setRanges($data['ranges']);
- }
-
- $annotation->setEntry($entry);
-
- $em->persist($annotation);
- $em->flush();
-
- $json = $this->get('serializer')->serialize($annotation, 'json');
-
- return $this->renderJsonResponse($json);