getDoctrine()->getManager(); $ejeMunicipals = $em->getRepository('UBVSurUbvBundle:EjeMunicipal')->findAll(); return $this->render('ejemunicipal/index.html.twig', array( 'ejeMunicipals' => $ejeMunicipals, )); } /** * Creates a new EjeMunicipal entity. * * @Route("/new", name="ejemunicipal_new") * @Method({"GET", "POST"}) */ public function newAction(Request $request) { $ejeMunicipal = new EjeMunicipal(); $form = $this->createForm('UBV\SurUbvBundle\Form\EjeMunicipalType', $ejeMunicipal); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($ejeMunicipal); $em->flush(); return $this->redirectToRoute('ejemunicipal_show', array('id' => $ejeMunicipal->getId())); } return $this->render('ejemunicipal/new.html.twig', array( 'ejeMunicipal' => $ejeMunicipal, 'form' => $form->createView(), )); } /** * * @Route("/ejemunicipals", name="select_ejemunicipal") * @Method("POST") */ public function ejemunicipalAction(Request $request) { //die(dump($request)); $ejeregional_id = $request->request->get('ejeregional_id'); $em = $this->getDoctrine()->getManager(); $ejemunicipal = $em->getRepository('UBVSurUbvBundle:EjeMunicipal')->findEjeMunicipalByEjeRegionalId($ejeregional_id); return new JsonResponse($ejemunicipal); } /** * Finds and displays a EjeMunicipal entity. * * @Route("/{id}", name="ejemunicipal_show") * @Method("GET") */ public function showAction(EjeMunicipal $ejeMunicipal) { $deleteForm = $this->createDeleteForm($ejeMunicipal); return $this->render('ejemunicipal/show.html.twig', array( 'ejeMunicipal' => $ejeMunicipal, 'delete_form' => $deleteForm->createView(), )); } /** * Displays a form to edit an existing EjeMunicipal entity. * * @Route("/{id}/edit", name="ejemunicipal_edit") * @Method({"GET", "POST"}) */ public function editAction(Request $request, EjeMunicipal $ejeMunicipal) { $deleteForm = $this->createDeleteForm($ejeMunicipal); $editForm = $this->createForm('UBV\SurUbvBundle\Form\EjeMunicipalType', $ejeMunicipal); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($ejeMunicipal); $em->flush(); return $this->redirectToRoute('ejemunicipal_edit', array('id' => $ejeMunicipal->getId())); } return $this->render('ejemunicipal/edit.html.twig', array( 'ejeMunicipal' => $ejeMunicipal, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), )); } /** * Deletes a EjeMunicipal entity. * * @Route("/{id}", name="ejemunicipal_delete") * @Method("DELETE") */ public function deleteAction(Request $request, EjeMunicipal $ejeMunicipal) { $form = $this->createDeleteForm($ejeMunicipal); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($ejeMunicipal); $em->flush(); } return $this->redirectToRoute('ejemunicipal_index'); } /** * Creates a form to delete a EjeMunicipal entity. * * @param EjeMunicipal $ejeMunicipal The EjeMunicipal entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(EjeMunicipal $ejeMunicipal) { return $this->createFormBuilder() ->setAction($this->generateUrl('ejemunicipal_delete', array('id' => $ejeMunicipal->getId()))) ->setMethod('DELETE') ->getForm() ; } }