EjeMunicipalController.php
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
namespace UBV\SurUbvBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use UBV\SurUbvBundle\Entity\EjeMunicipal;
use UBV\SurUbvBundle\Form\EjeMunicipalType;
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* EjeMunicipal controller.
*
* @Route("/ejemunicipal")
*/
class EjeMunicipalController extends Controller
{
/**
* Lists all EjeMunicipal entities.
*
* @Route("/", name="ejemunicipal_index")
* @Method("GET")
*/
public function indexAction()
{
$em = $this->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()
;
}
}