/** * @ParamConverter("post", class="Acme\BlogBundle\Entity\Post", options={"id" = "post_id"}) * @ParamConverter("comment", class="Acme\BlogBundle\Entity\Comment", options={"id" = "comment_id"}) * @param Post $post * @param Comment $comment * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function removeAction(Post $post, Comment $comment) { if (!$this->userHasAccess($comment)) { throw new AccessDeniedException("Comment cannot be remove"); } $em = $this->getDoctrine()->getEntityManager(); $em->remove($comment); $em->flush(); return $this->redirect($this->generateUrl('show_post', array('id' => $post->getId()))); }