diff --git a/app/Resources/views/banco/edit.html.twig b/app/Resources/views/banco/edit.html.twig
new file mode 100644
index 0000000..62e87b3
--- /dev/null
+++ b/app/Resources/views/banco/edit.html.twig
@@ -0,0 +1,21 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+
Banco edit
+
+ {{ form_start(edit_form) }}
+ {{ form_widget(edit_form) }}
+
+ {{ form_end(edit_form) }}
+
+
+{% endblock %}
diff --git a/app/Resources/views/banco/index.html.twig b/app/Resources/views/banco/index.html.twig
new file mode 100644
index 0000000..366e127
--- /dev/null
+++ b/app/Resources/views/banco/index.html.twig
@@ -0,0 +1,41 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Bancos list
+
+
+
+
+ Id |
+ Descripcion |
+ Codigo |
+ Actions |
+
+
+
+ {% for banco in bancos %}
+
+ {{ banco.id }} |
+ {{ banco.descripcion }} |
+ {{ banco.codigo }} |
+
+
+ |
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
diff --git a/app/Resources/views/banco/new.html.twig b/app/Resources/views/banco/new.html.twig
new file mode 100644
index 0000000..916e5eb
--- /dev/null
+++ b/app/Resources/views/banco/new.html.twig
@@ -0,0 +1,16 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Banco creation
+
+ {{ form_start(form) }}
+ {{ form_widget(form) }}
+
+ {{ form_end(form) }}
+
+
+{% endblock %}
diff --git a/app/Resources/views/banco/show.html.twig b/app/Resources/views/banco/show.html.twig
new file mode 100644
index 0000000..7905c64
--- /dev/null
+++ b/app/Resources/views/banco/show.html.twig
@@ -0,0 +1,36 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ Banco
+
+
+
+
+ Id |
+ {{ banco.id }} |
+
+
+ Descripcion |
+ {{ banco.descripcion }} |
+
+
+ Codigo |
+ {{ banco.codigo }} |
+
+
+
+
+
+{% endblock %}
diff --git a/src/UBV/PracticaBundle/Controller/BancoController.php b/src/UBV/PracticaBundle/Controller/BancoController.php
new file mode 100644
index 0000000..f66c47f
--- /dev/null
+++ b/src/UBV/PracticaBundle/Controller/BancoController.php
@@ -0,0 +1,136 @@
+getDoctrine()->getManager();
+
+ $bancos = $em->getRepository('UBVPracticaBundle:Banco')->findAll();
+
+ return $this->render('banco/index.html.twig', array(
+ 'bancos' => $bancos,
+ ));
+ }
+
+ /**
+ * Creates a new banco entity.
+ *
+ * @Route("/new", name="banco_new")
+ * @Method({"GET", "POST"})
+ */
+ public function newAction(Request $request)
+ {
+ $banco = new Banco();
+ $form = $this->createForm('UBV\PracticaBundle\Form\BancoType', $banco);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $em->persist($banco);
+ $em->flush(); $this->get('session')->getFlashBag()->set( 'success', array( 'title' => 'Guardado!', 'message' => 'Estado creado satisfactoriamente.' ) );
+
+ return $this->redirectToRoute(' $banco->getId()));
+ }
+
+ return $this->render('banco/new.html.twig', array(
+ 'banco' => $banco,
+ 'form' => $form->createView(),
+ ));
+ }
+
+ /**
+ * Finds and displays a banco entity.
+ *
+ * @Route("/{id}", name="banco_show")
+ * @Method("GET")
+ */
+ public function showAction(Banco $banco)
+ {
+ $deleteForm = $this->createDeleteForm($banco);
+
+ return $this->render('banco/show.html.twig', array(
+ 'banco' => $banco,
+ 'delete_form' => $deleteForm->createView(),
+ ));
+ }
+
+ /**
+ * Displays a form to edit an existing banco entity.
+ *
+ * @Route("/{id}/edit", name="banco_edit")
+ * @Method({"GET", "POST"})
+ */
+ public function editAction(Request $request, Banco $banco)
+ {
+ $deleteForm = $this->createDeleteForm($banco);
+ $editForm = $this->createForm('UBV\PracticaBundle\Form\BancoType', $banco);
+ $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('banco_edit', array('id' => $banco->getId()));
+ }
+
+ return $this->render('banco/edit.html.twig', array(
+ 'banco' => $banco,
+ 'edit_form' => $editForm->createView(),
+ 'delete_form' => $deleteForm->createView(),
+ ));
+ }
+
+ /**
+ * Deletes a banco entity.
+ *
+ * @Route("/{id}", name="banco_delete")
+ * @Method("DELETE")
+ */
+ public function deleteAction(Request $request, Banco $banco)
+ {
+ $form = $this->createDeleteForm($banco);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $em = $this->getDoctrine()->getManager();
+ $em->remove($banco);
+ $em->flush();
+ }
+
+ return $this->redirectToRoute('banco_index');
+ }
+
+ /**
+ * Creates a form to delete a banco entity.
+ *
+ * @param Banco $banco The banco entity
+ *
+ * @return \Symfony\Component\Form\Form The form
+ */
+ private function createDeleteForm(Banco $banco)
+ {
+ return $this->createFormBuilder()
+ ->setAction($this->generateUrl('banco_delete', array('id' => $banco->getId())))
+ ->setMethod('DELETE')
+ ->getForm()
+ ;
+ }
+}
diff --git a/src/UBV/PracticaBundle/Entity/Banco.php b/src/UBV/PracticaBundle/Entity/Banco.php
index f0ee2b8..1654c39 100644
--- a/src/UBV/PracticaBundle/Entity/Banco.php
+++ b/src/UBV/PracticaBundle/Entity/Banco.php
@@ -3,6 +3,7 @@
namespace UBV\PracticaBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
+use Symfony\Component\Validator\Constraints as Assert;
/**
* Banco
@@ -22,6 +23,14 @@ class Banco
private $id;
/**
+ *@Assert\NotBlank( message= "Por favor introduzca la Descripción del Banco")
+ *@Assert\NotNull(message= "Por favor introduzca la Descripción del Banco", groups={"Default"})
+*@Assert\Length(
+ * min = 5,
+ * max = 150,
+ * minMessage = "Por favor introduzca un Nombre de Banco más específico. Mínimo {{ limit }} caracteres",
+ * maxMessage = "Por favor introduzca un Nombre de Banco más breve. Máximo {{ limit }} caracteres",
+*)
* @var string
*
* @ORM\Column(name="descripcion", type="string", length=255)
@@ -29,8 +38,15 @@ class Banco
private $descripcion;
/**
+ *@Assert\NotBlank( message= "Por favor introduzca la Descripción del Banco")
+ *@Assert\NotNull(message= "Por favor introduzca la Descripción del Banco", groups={"Default"})
+*@Assert\Length(
+ * min = 5,
+ * max = 150,
+ * minMessage = "Por favor introduzca un Nombre de Banco más específico. Mínimo {{ limit }} caracteres",
+ * maxMessage = "Por favor introduzca un Nombre de Banco más breve. Máximo {{ limit }} caracteres",
+*)
* @var int
- *
* @ORM\Column(name="codigo", type="integer")
*/
private $codigo;
diff --git a/src/UBV/PracticaBundle/Form/BancoType.php b/src/UBV/PracticaBundle/Form/BancoType.php
new file mode 100644
index 0000000..c540052
--- /dev/null
+++ b/src/UBV/PracticaBundle/Form/BancoType.php
@@ -0,0 +1,39 @@
+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( 'attr' => array('class' => 'form-control','placeholder'=>'codigo del Estado'), 'label_attr' => array('class' => 'control-label'), ));
+ }/**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'UBV\PracticaBundle\Entity\Banco'
+ ));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return 'ubv_practicabundle_banco';
+ }
+
+
+}
diff --git a/src/UBV/PracticaBundle/Tests/Controller/BancoControllerTest.php b/src/UBV/PracticaBundle/Tests/Controller/BancoControllerTest.php
new file mode 100644
index 0000000..c12575e
--- /dev/null
+++ b/src/UBV/PracticaBundle/Tests/Controller/BancoControllerTest.php
@@ -0,0 +1,55 @@
+request('GET', '/banco/');
+ $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /banco/");
+ $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_banco[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_banco[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());
+ }
+
+ */
+}