/** * Deletes a post. * * @ApiDoc( * requirements={ * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="post identifier"} * }, * statusCodes={ * 200="Returned when post is successfully deleted", * 400="Returned when an error has occurred while post deletion", * 404="Returned when unable to find post" * } * ) * * @Route(requirements={"_format"="json|xml"}) * * @param int $id A Post identifier * * @return \FOS\RestBundle\View\View * * @throws NotFoundHttpException */ public function deletePostAction($id) { $post = $this->getPost($id); try { $this->postManager->delete($post); } catch (\Exception $e) { return \FOS\RestBundle\View\View::create(array('error' => $e->getMessage()), 400); } return array('deleted' => true); }