コード例 #1
0
 /**
  * @Route("/delete_statement/{id}",name="delete_statement")
  * @ParamConverter("statement", class="AppBundle:Statement")
  * @Security("has_role('ROLE_ADMIN')")
  */
 public function delete_statement(Statement $statement)
 {
     $client_id = $statement->getClient()->getId();
     $em = $this->getDoctrine()->getManager();
     $em->remove($statement);
     $em->flush();
     return $this->redirectToRoute('productdetail', array('id' => $client_id));
 }
コード例 #2
0
 /**
  * Creates a form to delete a Statement entity by id.
  *
  * This is necessary because browsers don't support HTTP methods different
  * from GET and POST. Since the controller that removes the blog posts expects
  * a DELETE method, the trick is to create a simple form that *fakes* the
  * HTTP DELETE method.
  * See http://symfony.com/doc/current/cookbook/routing/method_parameters.html.
  *
  * @param  Statement $statement The statement object
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Statement $statement)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('statement_post_delete', array('id' => $statement->getId())))->setMethod('DELETE')->getForm();
 }