public function create($data) { if ($this->authorizedRequest()) { $em = $this->getEntityManager(); $album = new Album(); $album->setArtist($data['artist']); $album->setTitle($data['title']); $em->persist($album); $em->flush(); return new JsonModel(array('data' => $album->getId())); } else { return $this->defaultFailure(); } }