getDoctrine()->getManager(); $arancels = $em->getRepository('UBVSurUbvBundle:Arancel')->findAll(); return $this->render('arancel/index.html.twig', array( 'arancels' => $arancels, )); } /** * Creates a new arancel entity. * * @Route("/new", name="arancel_new") * @Method({"GET", "POST"}) */ public function newAction(Request $request) { $arancel = new Arancel(); $form = $this->createForm('UBV\SurUbvBundle\Form\ArancelType', $arancel); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($arancel); $em->flush(); return $this->redirectToRoute('arancel_show', array('id' => $arancel->getId())); } return $this->render('arancel/new.html.twig', array( 'arancel' => $arancel, 'form' => $form->createView(), )); } /** * Finds and displays a arancel entity. * * @Route("/{id}", name="arancel_show") * @Method("GET") */ public function showAction(Arancel $arancel) { $deleteForm = $this->createDeleteForm($arancel); return $this->render('arancel/show.html.twig', array( 'arancel' => $arancel, 'delete_form' => $deleteForm->createView(), )); } /** * Displays a form to edit an existing arancel entity. * * @Route("/{id}/edit", name="arancel_edit") * @Method({"GET", "POST"}) */ public function editAction(Request $request, Arancel $arancel) { $deleteForm = $this->createDeleteForm($arancel); $editForm = $this->createForm('UBV\SurUbvBundle\Form\ArancelType', $arancel); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirectToRoute('arancel_edit', array('id' => $arancel->getId())); } return $this->render('arancel/edit.html.twig', array( 'arancel' => $arancel, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), )); } /** * Deletes a arancel entity. * * @Route("/{id}", name="arancel_delete") * @Method("DELETE") */ public function deleteAction(Request $request, Arancel $arancel) { $form = $this->createDeleteForm($arancel); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($arancel); $em->flush(); } return $this->redirectToRoute('arancel_index'); } /** * Creates a form to delete a arancel entity. * * @param Arancel $arancel The arancel entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Arancel $arancel) { return $this->createFormBuilder() ->setAction($this->generateUrl('arancel_delete', array('id' => $arancel->getId()))) ->setMethod('DELETE') ->getForm() ; } }