/** * @Route("/create") */ public function createAction() { $request = $this->get('request'); $data = $request->request->all(); $name = $data['name']; $phone = $data['phone']; if (!empty($name) && !empty($phone)) { $record = new Phonebook(); $record->setName($name); $record->setPhone($phone); $em = $this->getDoctrine()->getManager(); $em->persist($record); $em->flush(); $result = array("status" => "success", "result" => array("id" => $record->getId(), "name" => $name, "phone" => $phone)); } else { $result = array("status" => "failure", "result" => "Haven't created any record, not enough data."); } return new JsonResponse($result); }
/** * {@inheritDoc} */ public function getPhone() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPhone', array()); return parent::getPhone(); }