getDoctrine()->getManager(); $telefonoTipos = $em->getRepository('UBVSurUbvBundle:TelefonoTipo')->findAll(); return $this->render('telefonotipo/index.html.twig', array( 'telefonoTipos' => $telefonoTipos, )); } /** * Creates a new TelefonoTipo entity. * * @Route("/new", name="telefonotipo_new") * @Method({"GET", "POST"}) */ public function newAction(Request $request) { $telefonoTipo = new TelefonoTipo(); $form = $this->createForm('UBV\SurUbvBundle\Form\TelefonoTipoType', $telefonoTipo); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($telefonoTipo); $em->flush(); $this->get('session')->getFlashBag()->set( 'success', array( 'title' => 'Guardado!', 'message' => 'Tipo de Telefono creado satisfactoriamente.' ) ); return $this->redirectToRoute('telefonotipo_index', array('id' => $telefonoTipo->getId())); } return $this->render('telefonotipo/new.html.twig', array( 'telefonoTipo' => $telefonoTipo, 'form' => $form->createView(), )); } /** * Finds and displays a TelefonoTipo entity. * * @Route("/{id}", name="telefonotipo_show") * @Method("GET") */ public function showAction(TelefonoTipo $telefonoTipo) { return $this->render('telefonotipo/show.html.twig', array( 'telefonoTipo' => $telefonoTipo, )); } /** * Displays a form to edit an existing TelefonoTipo entity. * * @Route("/{id}/edit", name="telefonotipo_edit") * @Method({"GET", "POST"}) */ public function editAction(Request $request, TelefonoTipo $telefonoTipo) { $editForm = $this->createForm('UBV\SurUbvBundle\Form\TelefonoTipoType', $telefonoTipo); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($telefonoTipo); $em->flush(); $this->get('session')->getFlashBag()->set( 'success', array( 'title' => 'Editado!', 'message' => 'Tipo de Telefono Editado satisfactoriamente.' ) ); return $this->redirectToRoute('telefonotipo_index', array('id' => $telefonoTipo->getId())); } return $this->render('telefonotipo/edit.html.twig', array( 'telefonoTipo' => $telefonoTipo, 'edit_form' => $editForm->createView(), )); } /** * Deletes a TelefonoTipo entity. * * @Route("/borrar/{id}", name="telefonotipo_delete") <--- aqui le defines la ruta que va a tomar--> * @Method("GET") */ public function deleteAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('UBVSurUbvBundle:TelefonoTipo')->Find($id); $em->remove($entity); $em->flush(); $this->get('session')->getFlashBag()->set( 'danger', array( 'title' => 'Eliminado!', 'message' => 'Tipo de Telefono Eliminado satisfactoriamente.' ) ); return $this->redirectToRoute('telefonotipo_index'); } /** * Creates a form to delete a TelefonoTipo entity. * * @param TelefonoTipo $id The TelefonoTipo entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm($id) { return $this->createFormBuilder() ->setAction($this->generateUrl('telefonotipo_delete', array('id' => $id))) ->setMethod('DELETE') ->getForm() ; } }