diff --git a/app/Resources/views/ambiente/edit.html.twig b/app/Resources/views/ambiente/edit.html.twig
new file mode 100644
index 0000000..6e8903b
--- /dev/null
+++ b/app/Resources/views/ambiente/edit.html.twig
@@ -0,0 +1,21 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
Ambiente edit
+
+ {{ form_start(edit_form) }}
+ {{ form_widget(edit_form) }}
+
+ {{ form_end(edit_form) }}
+
+
+{% endblock %}
diff --git a/app/Resources/views/ambiente/index.html.twig b/app/Resources/views/ambiente/index.html.twig
new file mode 100644
index 0000000..e2169fa
--- /dev/null
+++ b/app/Resources/views/ambiente/index.html.twig
@@ -0,0 +1,47 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Ambientes list
+
+
+
+
+ Id |
+ Descripcion |
+ Codigo |
+ Direccion |
+ Coordenadautmnorte |
+ Coordenadautmoeste |
+ Actions |
+
+
+
+ {% for ambiente in ambientes %}
+
+ {{ ambiente.id }} |
+ {{ ambiente.descripcion }} |
+ {{ ambiente.codigo }} |
+ {{ ambiente.direccion }} |
+ {{ ambiente.coordenadaUtmNorte }} |
+ {{ ambiente.coordenadaUtmOeste }} |
+
+
+ |
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
diff --git a/app/Resources/views/ambiente/new.html.twig b/app/Resources/views/ambiente/new.html.twig
new file mode 100644
index 0000000..d1e08a9
--- /dev/null
+++ b/app/Resources/views/ambiente/new.html.twig
@@ -0,0 +1,16 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Ambiente creation
+
+ {{ form_start(form) }}
+ {{ form_widget(form) }}
+
+ {{ form_end(form) }}
+
+
+{% endblock %}
diff --git a/app/Resources/views/ambiente/show.html.twig b/app/Resources/views/ambiente/show.html.twig
new file mode 100644
index 0000000..a757db7
--- /dev/null
+++ b/app/Resources/views/ambiente/show.html.twig
@@ -0,0 +1,48 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Ambiente
+
+
+
+
+ Id |
+ {{ ambiente.id }} |
+
+
+ Descripcion |
+ {{ ambiente.descripcion }} |
+
+
+ Codigo |
+ {{ ambiente.codigo }} |
+
+
+ Direccion |
+ {{ ambiente.direccion }} |
+
+
+ Coordenadautmnorte |
+ {{ ambiente.coordenadaUtmNorte }} |
+
+
+ Coordenadautmoeste |
+ {{ ambiente.coordenadaUtmOeste }} |
+
+
+
+
+
+{% endblock %}
diff --git a/src/UBV/PracticaBundle/Controller/ambienteController.php b/src/UBV/PracticaBundle/Controller/ambienteController.php
new file mode 100644
index 0000000..a57a1fa
--- /dev/null
+++ b/src/UBV/PracticaBundle/Controller/ambienteController.php
@@ -0,0 +1,138 @@
+getDoctrine()->getManager();
+
+ $ambientes = $em->getRepository('UBVPracticaBundle:ambiente')->findAll();
+
+ return $this->render('ambiente/index.html.twig', array(
+ 'ambientes' => $ambientes,
+ ));
+ }
+
+ /**
+ * Creates a new ambiente entity.
+ *
+ * @Route("/new", name="ambiente_new")
+ * @Method({"GET", "POST"})
+ */
+ public function newAction(Request $request)
+ {
+ $ambiente = new Ambiente();
+ $form = $this->createForm('UBV\PracticaBundle\Form\ambienteType', $ambiente);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $em->persist($ambiente);
+ $em->flush();
+ $this->get('session')->getFlashBag()->set( 'success', array( 'title' => 'Guardado!', 'message' => 'Estado creado satisfactoriamente.' ) );
+
+ return $this->redirectToRoute('ambiente_index', array('id' => $ambiente->getId()));
+ }
+
+ return $this->render('ambiente/new.html.twig', array(
+ 'ambiente' => $ambiente,
+ 'form' => $form->createView(),
+ ));
+ }
+
+ /**
+ * Finds and displays a ambiente entity.
+ *
+ * @Route("/{id}", name="ambiente_show")
+ * @Method("GET")
+ */
+ public function showAction(ambiente $ambiente)
+ {
+ $deleteForm = $this->createDeleteForm($ambiente);
+
+ return $this->render('ambiente/show.html.twig', array(
+ 'ambiente' => $ambiente,
+ 'delete_form' => $deleteForm->createView(),
+ ));
+ }
+
+ /**
+ * Displays a form to edit an existing ambiente entity.
+ *
+ * @Route("/{id}/edit", name="ambiente_edit")
+ * @Method({"GET", "POST"})
+ */
+ public function editAction(Request $request, ambiente $ambiente)
+ {
+ $deleteForm = $this->createDeleteForm($ambiente);
+ $editForm = $this->createForm('UBV\PracticaBundle\Form\ambienteType', $ambiente);
+ $editForm->handleRequest($request);
+
+ if ($editForm->isSubmitted() && $editForm->isValid()) {
+ $this->getDoctrine()->getManager()->flush();
+ $this->get('session')->getFlashBag()->set( 'success', array( 'title' => 'Guardado!', 'message' => 'Estado editado satisfactoriamente.' ) );
+ return $this->redirectToRoute('ambiente_edit', array('id' => $ambiente->getId()));
+ }
+
+ return $this->render('ambiente/edit.html.twig', array(
+ 'ambiente' => $ambiente,
+ 'edit_form' => $editForm->createView(),
+ 'delete_form' => $deleteForm->createView(),
+ ));
+ }
+
+ /**
+ * Deletes a ambiente entity.
+ *
+ * @Route("/{id}", name="ambiente_delete")
+ * @Method("DELETE")
+ */
+ public function deleteAction(Request $request, ambiente $ambiente)
+ {
+ $form = $this->createDeleteForm($ambiente);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $em->remove($ambiente);
+ $em->flush();
+
+ }
+
+ return $this->redirectToRoute('ambiente_index');
+ }
+
+ /**
+ * Creates a form to delete a ambiente entity.
+ *
+ * @param ambiente $ambiente The ambiente entity
+ *
+ * @return \Symfony\Component\Form\Form The form
+ */
+ private function createDeleteForm(ambiente $ambiente)
+ {
+ return $this->createFormBuilder()
+ ->setAction($this->generateUrl('ambiente_delete', array('id' => $ambiente->getId())))
+ ->setMethod('DELETE')
+ ->getForm()
+ ;
+ }
+}
diff --git a/src/UBV/PracticaBundle/Entity/ambiente.php b/src/UBV/PracticaBundle/Entity/ambiente.php
index a808325..a1985d5 100644
--- a/src/UBV/PracticaBundle/Entity/ambiente.php
+++ b/src/UBV/PracticaBundle/Entity/ambiente.php
@@ -3,6 +3,7 @@
namespace UBV\PracticaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
/**
* ambiente
@@ -20,20 +21,35 @@ class ambiente
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
-
/**
+ * @Assert\NotBlank( message= "Por favor introduzca la Descripción del ambiente")
+ * @Assert\NotNull(message= "Por favor introduzca la Descripción del ambiente", groups={"Default"})
+ *@Assert\Length(
+ * min = 5,
+ * max = 100,
+ * minMessage = "Por favor introduzca una descripcion del ambiente más específico. Mínimo {{ limit }} caracteres",
+ * maxMessage = "Por favor introduzca un Nombre del ambiente más breve. Máximo {{ limit }} caracteres",
+ *)
* @var string
- *
- * @ORM\Column(name="descripcion", type="string", length=255)
+ *
+ * @ORM\Column(name="descripcion", type="string", length=50)
*/
private $descripcion;
/**
+ * @Assert\NotBlank( message= "Por favor introduzca un codigo del ambiente")
+ * @Assert\NotNull(message= "Por favor introduzca un codigo del ambiente", groups={"Default"})
+ *@Assert\Length(
+ * min = 5,
+ * max = 30,
+ * minMessage = "Por favor introduzca una descripcion del ambiente más específico. Mínimo {{ limit }} caracteres",
+ * maxMessage = "Por favor introduzca un Nombre del ambiente más breve. Máximo {{ limit }} caracteres",
+ *)
* @var int
*
* @ORM\Column(name="codigo", type="integer")
*/
- private $codigo;
+ private $codigo;
/**
* @var string
diff --git a/src/UBV/PracticaBundle/Form/ambienteType.php b/src/UBV/PracticaBundle/Form/ambienteType.php
new file mode 100644
index 0000000..79d79f4
--- /dev/null
+++ b/src/UBV/PracticaBundle/Form/ambienteType.php
@@ -0,0 +1,75 @@
+add('descripcion','text', array('label'
+ => 'Descripción del Estado', 'attr'
+ => array('class'
+ => 'form-control','placeholder'
+ =>'Descripcion del Estado'), 'label_attr'
+ => array('class'
+ => 'control-label'), ))
+
+ ->add('codigo','integer', array('label'
+ => 'codigo', 'attr'
+ => array('class'
+ => 'form-control','placeholder'
+ =>'Descripcion del Estado'), 'label_attr'
+ => array('class'
+ => 'control-label'), ))
+
+ ->add('direccion','text', array('label'
+ => 'Direccion del ambiente', 'attr'
+ => array('class'
+ => 'form-control','placeholder'
+ =>'Descripcion del Estado'), 'label_attr'
+ => array('class'
+ => 'control-label'), ))
+
+ ->add('coordenadaUtmNorte','text', array('label'
+ => 'coordenadas norte', 'attr'
+ => array('class'
+ => 'form-control','placeholder'
+ =>'Descripcion del Estado'), 'label_attr'
+ => array('class'
+ => 'control-label'), ))
+
+ ->add('coordenadaUtmOeste','text', array('label'
+ => 'cordenadas este', 'attr'
+ => array('class'
+ => 'form-control','placeholder'
+ =>'Descripcion del Estado'), 'label_attr'
+ => array('class'
+ => 'control-label'), ));
+ }/**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'UBV\PracticaBundle\Entity\ambiente'
+ ));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return 'ubv_practicabundle_ambiente';
+ }
+
+
+}
diff --git a/src/UBV/PracticaBundle/Tests/Controller/ambienteControllerTest.php b/src/UBV/PracticaBundle/Tests/Controller/ambienteControllerTest.php
new file mode 100644
index 0000000..04ba8d2
--- /dev/null
+++ b/src/UBV/PracticaBundle/Tests/Controller/ambienteControllerTest.php
@@ -0,0 +1,55 @@
+request('GET', '/ambiente/');
+ $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /ambiente/");
+ $crawler = $client->click($crawler->selectLink('Create a new entry')->link());
+
+ // Fill in the form and submit it
+ $form = $crawler->selectButton('Create')->form(array(
+ 'ubv_practicabundle_ambiente[field_name]' => 'Test',
+ // ... other fields to fill
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check data in the show view
+ $this->assertGreaterThan(0, $crawler->filter('td:contains("Test")')->count(), 'Missing element td:contains("Test")');
+
+ // Edit the entity
+ $crawler = $client->click($crawler->selectLink('Edit')->link());
+
+ $form = $crawler->selectButton('Update')->form(array(
+ 'ubv_practicabundle_ambiente[field_name]' => 'Foo',
+ // ... other fields to fill
+ ));
+
+ $client->submit($form);
+ $crawler = $client->followRedirect();
+
+ // Check the element contains an attribute with value equals "Foo"
+ $this->assertGreaterThan(0, $crawler->filter('[value="Foo"]')->count(), 'Missing element [value="Foo"]');
+
+ // Delete the entity
+ $client->submit($crawler->selectButton('Delete')->form());
+ $crawler = $client->followRedirect();
+
+ // Check the entity has been delete on the list
+ $this->assertNotRegExp('/Foo/', $client->getResponse()->getContent());
+ }
+
+ */
+}