From 9512528018a2e81859c4e7f2be965684fa9f78ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 18 Mar 2016 11:34:25 +0100 Subject: [PATCH] add basic crud for admin --- .gitignore | 21 ++ Controller/EventTypeController.php | 224 +++++++++++++++++++ Controller/RoleController.php | 224 +++++++++++++++++++ Controller/StatusController.php | 224 +++++++++++++++++++ DependencyInjection/ChillEventExtension.php | 2 +- Form/EventTypeType.php | 40 ++++ Form/RoleType.php | 41 ++++ Form/StatusType.php | 41 ++++ Resources/config/routing.yml | 15 +- Resources/config/routing/eventtype.yml | 30 +++ Resources/config/routing/role.yml | 30 +++ Resources/config/routing/status.yml | 30 +++ Resources/views/EventType/edit.html.twig | 16 ++ Resources/views/EventType/index.html.twig | 43 ++++ Resources/views/EventType/new.html.twig | 15 ++ Resources/views/EventType/show.html.twig | 36 +++ Resources/views/Role/edit.html.twig | 16 ++ Resources/views/Role/index.html.twig | 43 ++++ Resources/views/Role/new.html.twig | 15 ++ Resources/views/Role/show.html.twig | 36 +++ Resources/views/Status/edit.html.twig | 16 ++ Resources/views/Status/index.html.twig | 43 ++++ Resources/views/Status/new.html.twig | 15 ++ Resources/views/Status/show.html.twig | 36 +++ Tests/Controller/EventTypeControllerTest.php | 55 +++++ Tests/Controller/RoleControllerTest.php | 55 +++++ Tests/Controller/StatusControllerTest.php | 55 +++++ 27 files changed, 1413 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 Controller/EventTypeController.php create mode 100644 Controller/RoleController.php create mode 100644 Controller/StatusController.php create mode 100644 Form/EventTypeType.php create mode 100644 Form/RoleType.php create mode 100644 Form/StatusType.php create mode 100644 Resources/config/routing/eventtype.yml create mode 100644 Resources/config/routing/role.yml create mode 100644 Resources/config/routing/status.yml create mode 100644 Resources/views/EventType/edit.html.twig create mode 100644 Resources/views/EventType/index.html.twig create mode 100644 Resources/views/EventType/new.html.twig create mode 100644 Resources/views/EventType/show.html.twig create mode 100644 Resources/views/Role/edit.html.twig create mode 100644 Resources/views/Role/index.html.twig create mode 100644 Resources/views/Role/new.html.twig create mode 100644 Resources/views/Role/show.html.twig create mode 100644 Resources/views/Status/edit.html.twig create mode 100644 Resources/views/Status/index.html.twig create mode 100644 Resources/views/Status/new.html.twig create mode 100644 Resources/views/Status/show.html.twig create mode 100644 Tests/Controller/EventTypeControllerTest.php create mode 100644 Tests/Controller/RoleControllerTest.php create mode 100644 Tests/Controller/StatusControllerTest.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..9f103fd7c --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +*~ +# MacOS +.DS_Store + +# Bootstrap +app/bootstrap* + +# Symfony directories +vendor/* +*/logs/* +*/cache/* +web/uploads/* +web/bundles/* + +# Configuration files +app/config/parameters.ini +app/config/parameters.yml +Tests/Fixtures/App/config/parameters.yml + +#composer +composer.lock diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php new file mode 100644 index 000000000..cbe28999b --- /dev/null +++ b/Controller/EventTypeController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:EventType')->findAll(); + + return $this->render('ChillEventBundle:EventType:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new EventType entity. + * + */ + public function createAction(Request $request) + { + $entity = new EventType(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:EventType:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a EventType entity. + * + * @param EventType $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(EventType $entity) + { + $form = $this->createForm(new EventTypeType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new EventType entity. + * + */ + public function newAction() + { + $entity = new EventType(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:EventType:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a EventType entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:EventType:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing EventType entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:EventType:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a EventType entity. + * + * @param EventType $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(EventType $entity) + { + $form = $this->createForm(new EventTypeType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing EventType entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:EventType:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a EventType entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:EventType')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find EventType entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('{_locale}_admin')); + } + + /** + * Creates a form to delete a EventType entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('{_locale}_admin_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/Controller/RoleController.php b/Controller/RoleController.php new file mode 100644 index 000000000..3834e89a9 --- /dev/null +++ b/Controller/RoleController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:Role')->findAll(); + + return $this->render('ChillEventBundle:Role:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new Role entity. + * + */ + public function createAction(Request $request) + { + $entity = new Role(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_role_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:Role:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a Role entity. + * + * @param Role $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Role $entity) + { + $form = $this->createForm(new RoleType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_role_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new Role entity. + * + */ + public function newAction() + { + $entity = new Role(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:Role:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Role entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Role:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Role entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Role:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a Role entity. + * + * @param Role $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Role $entity) + { + $form = $this->createForm(new RoleType(), $entity, array( + 'action' => $this->generateUrl('{_locale}_admin_role_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing Role entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('{_locale}_admin_role_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:Role:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a Role entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:Role')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Role entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('{_locale}_admin_role')); + } + + /** + * Creates a form to delete a Role entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('{_locale}_admin_role_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/Controller/StatusController.php b/Controller/StatusController.php new file mode 100644 index 000000000..e0a57ba51 --- /dev/null +++ b/Controller/StatusController.php @@ -0,0 +1,224 @@ +getDoctrine()->getManager(); + + $entities = $em->getRepository('ChillEventBundle:Status')->findAll(); + + return $this->render('ChillEventBundle:Status:index.html.twig', array( + 'entities' => $entities, + )); + } + /** + * Creates a new Status entity. + * + */ + public function createAction(Request $request) + { + $entity = new Status(); + $form = $this->createCreateForm($entity); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $em->persist($entity); + $em->flush(); + + return $this->redirect($this->generateUrl('fr_admin_event_status_show', array('id' => $entity->getId()))); + } + + return $this->render('ChillEventBundle:Status:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Creates a form to create a Status entity. + * + * @param Status $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createCreateForm(Status $entity) + { + $form = $this->createForm(new StatusType(), $entity, array( + 'action' => $this->generateUrl('fr_admin_event_status_create'), + 'method' => 'POST', + )); + + $form->add('submit', 'submit', array('label' => 'Create')); + + return $form; + } + + /** + * Displays a form to create a new Status entity. + * + */ + public function newAction() + { + $entity = new Status(); + $form = $this->createCreateForm($entity); + + return $this->render('ChillEventBundle:Status:new.html.twig', array( + 'entity' => $entity, + 'form' => $form->createView(), + )); + } + + /** + * Finds and displays a Status entity. + * + */ + public function showAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Status:show.html.twig', array( + 'entity' => $entity, + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Displays a form to edit an existing Status entity. + * + */ + public function editAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $editForm = $this->createEditForm($entity); + $deleteForm = $this->createDeleteForm($id); + + return $this->render('ChillEventBundle:Status:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + + /** + * Creates a form to edit a Status entity. + * + * @param Status $entity The entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createEditForm(Status $entity) + { + $form = $this->createForm(new StatusType(), $entity, array( + 'action' => $this->generateUrl('fr_admin_event_status_update', array('id' => $entity->getId())), + 'method' => 'PUT', + )); + + $form->add('submit', 'submit', array('label' => 'Update')); + + return $form; + } + /** + * Edits an existing Status entity. + * + */ + public function updateAction(Request $request, $id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $deleteForm = $this->createDeleteForm($id); + $editForm = $this->createEditForm($entity); + $editForm->handleRequest($request); + + if ($editForm->isValid()) { + $em->flush(); + + return $this->redirect($this->generateUrl('fr_admin_event_status_edit', array('id' => $id))); + } + + return $this->render('ChillEventBundle:Status:edit.html.twig', array( + 'entity' => $entity, + 'edit_form' => $editForm->createView(), + 'delete_form' => $deleteForm->createView(), + )); + } + /** + * Deletes a Status entity. + * + */ + public function deleteAction(Request $request, $id) + { + $form = $this->createDeleteForm($id); + $form->handleRequest($request); + + if ($form->isValid()) { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository('ChillEventBundle:Status')->find($id); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Status entity.'); + } + + $em->remove($entity); + $em->flush(); + } + + return $this->redirect($this->generateUrl('fr_admin_event_status')); + } + + /** + * Creates a form to delete a Status entity by id. + * + * @param mixed $id The entity id + * + * @return \Symfony\Component\Form\Form The form + */ + private function createDeleteForm($id) + { + return $this->createFormBuilder() + ->setAction($this->generateUrl('fr_admin_event_status_delete', array('id' => $id))) + ->setMethod('DELETE') + ->add('submit', 'submit', array('label' => 'Delete')) + ->getForm() + ; + } +} diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 89eb98c57..1035659fd 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ -class ChillEventExtension extends Extension +class ChillEventExtension extends Extension implements PrependExtensionInterface { /** * {@inheritdoc} diff --git a/Form/EventTypeType.php b/Form/EventTypeType.php new file mode 100644 index 000000000..02ec828e8 --- /dev/null +++ b/Form/EventTypeType.php @@ -0,0 +1,40 @@ +add('label') + ->add('active') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\EventType' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_eventtype'; + } +} diff --git a/Form/RoleType.php b/Form/RoleType.php new file mode 100644 index 000000000..293aec1d1 --- /dev/null +++ b/Form/RoleType.php @@ -0,0 +1,41 @@ +add('label') + ->add('active') + ->add('type') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\Role' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_role'; + } +} diff --git a/Form/StatusType.php b/Form/StatusType.php new file mode 100644 index 000000000..24bdcd604 --- /dev/null +++ b/Form/StatusType.php @@ -0,0 +1,41 @@ +add('label') + ->add('active') + ->add('type') + ; + } + + /** + * @param OptionsResolverInterface $resolver + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(array( + 'data_class' => 'Chill\EventBundle\Entity\Status' + )); + } + + /** + * @return string + */ + public function getName() + { + return 'chill_eventbundle_status'; + } +} diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 712a131e6..f6262b049 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,3 +1,12 @@ -chill_event_homepage: - path: /hello/{name} - defaults: { _controller: ChillEventBundle:Default:index } +chill_event_fr_admin_event_status: + resource: "@ChillEventBundle/Resources/config/routing/status.yml" + prefix: /{_locale}/admin/event/status + +chill_event_admin_role: + resource: "@ChillEventBundle/Resources/config/routing/role.yml" + prefix: /{_locale}/admin/event/role + +chill_event_admin_event_type: + resource: "@ChillEventBundle/Resources/config/routing/eventtype.yml" + prefix: /{_locale}/admin/event/event_type + diff --git a/Resources/config/routing/eventtype.yml b/Resources/config/routing/eventtype.yml new file mode 100644 index 000000000..cdf54fe85 --- /dev/null +++ b/Resources/config/routing/eventtype.yml @@ -0,0 +1,30 @@ +chill_event_admin: + path: / + defaults: { _controller: "ChillEventBundle:EventType:index" } + +chill_event_admin_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:EventType:show" } + +chill_event_admin_new: + path: /new + defaults: { _controller: "ChillEventBundle:EventType:new" } + +chill_event_admin_create: + path: /create + defaults: { _controller: "ChillEventBundle:EventType:create" } + methods: POST + +chill_event_admin_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:EventType:edit" } + +chill_event_admin_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:EventType:update" } + methods: [POST, PUT] + +chill_event_admin_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:EventType:delete" } + methods: [POST, DELETE] diff --git a/Resources/config/routing/role.yml b/Resources/config/routing/role.yml new file mode 100644 index 000000000..bfc51216d --- /dev/null +++ b/Resources/config/routing/role.yml @@ -0,0 +1,30 @@ +chill_event_admin_role: + path: / + defaults: { _controller: "ChillEventBundle:Role:index" } + +chill_event_admin_role_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:Role:show" } + +chill_event_admin_role_new: + path: /new + defaults: { _controller: "ChillEventBundle:Role:new" } + +chill_event_admin_role_create: + path: /create + defaults: { _controller: "ChillEventBundle:Role:create" } + methods: POST + +chill_event_admin_role_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:Role:edit" } + +chill_event_admin_role_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:Role:update" } + methods: [POST, PUT] + +chill_event_admin_role_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:Role:delete" } + methods: [POST, DELETE] diff --git a/Resources/config/routing/status.yml b/Resources/config/routing/status.yml new file mode 100644 index 000000000..396f72c39 --- /dev/null +++ b/Resources/config/routing/status.yml @@ -0,0 +1,30 @@ +fr_admin_event_status: + path: / + defaults: { _controller: "ChillEventBundle:Status:index" } + +fr_admin_event_status_show: + path: /{id}/show + defaults: { _controller: "ChillEventBundle:Status:show" } + +fr_admin_event_status_new: + path: /new + defaults: { _controller: "ChillEventBundle:Status:new" } + +fr_admin_event_status_create: + path: /create + defaults: { _controller: "ChillEventBundle:Status:create" } + methods: POST + +fr_admin_event_status_edit: + path: /{id}/edit + defaults: { _controller: "ChillEventBundle:Status:edit" } + +fr_admin_event_status_update: + path: /{id}/update + defaults: { _controller: "ChillEventBundle:Status:update" } + methods: [POST, PUT] + +fr_admin_event_status_delete: + path: /{id}/delete + defaults: { _controller: "ChillEventBundle:Status:delete" } + methods: [POST, DELETE] diff --git a/Resources/views/EventType/edit.html.twig b/Resources/views/EventType/edit.html.twig new file mode 100644 index 000000000..5849fa686 --- /dev/null +++ b/Resources/views/EventType/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/EventType/index.html.twig b/Resources/views/EventType/index.html.twig new file mode 100644 index 000000000..72c47e279 --- /dev/null +++ b/Resources/views/EventType/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelActiveActions
{{ entity.id }}{{ entity.label }}{{ entity.active }} + +
+ + + {% endblock %} diff --git a/Resources/views/EventType/new.html.twig b/Resources/views/EventType/new.html.twig new file mode 100644 index 000000000..4e097dd92 --- /dev/null +++ b/Resources/views/EventType/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/EventType/show.html.twig b/Resources/views/EventType/show.html.twig new file mode 100644 index 000000000..818e30fa9 --- /dev/null +++ b/Resources/views/EventType/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

EventType

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Active{{ entity.active }}
+ + +{% endblock %} diff --git a/Resources/views/Role/edit.html.twig b/Resources/views/Role/edit.html.twig new file mode 100644 index 000000000..1bf9dc66d --- /dev/null +++ b/Resources/views/Role/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/Role/index.html.twig b/Resources/views/Role/index.html.twig new file mode 100644 index 000000000..dcfda2a25 --- /dev/null +++ b/Resources/views/Role/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelActiveActions
{{ entity.id }}{{ entity.label }}{{ entity.active }} + +
+ + + {% endblock %} diff --git a/Resources/views/Role/new.html.twig b/Resources/views/Role/new.html.twig new file mode 100644 index 000000000..a9ea41a1b --- /dev/null +++ b/Resources/views/Role/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/Role/show.html.twig b/Resources/views/Role/show.html.twig new file mode 100644 index 000000000..a212c2f6d --- /dev/null +++ b/Resources/views/Role/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Role

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Active{{ entity.active }}
+ + +{% endblock %} diff --git a/Resources/views/Status/edit.html.twig b/Resources/views/Status/edit.html.twig new file mode 100644 index 000000000..f9c2f7bda --- /dev/null +++ b/Resources/views/Status/edit.html.twig @@ -0,0 +1,16 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status edit

+ + {{ form(edit_form) }} + + +{% endblock %} diff --git a/Resources/views/Status/index.html.twig b/Resources/views/Status/index.html.twig new file mode 100644 index 000000000..e5ec9e480 --- /dev/null +++ b/Resources/views/Status/index.html.twig @@ -0,0 +1,43 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status list

+ + + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
IdLabelActiveActions
{{ entity.id }}{{ entity.label }}{{ entity.active }} + +
+ + + {% endblock %} diff --git a/Resources/views/Status/new.html.twig b/Resources/views/Status/new.html.twig new file mode 100644 index 000000000..7cd7093b1 --- /dev/null +++ b/Resources/views/Status/new.html.twig @@ -0,0 +1,15 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status creation

+ + {{ form(form) }} + + +{% endblock %} diff --git a/Resources/views/Status/show.html.twig b/Resources/views/Status/show.html.twig new file mode 100644 index 000000000..7b0dd4049 --- /dev/null +++ b/Resources/views/Status/show.html.twig @@ -0,0 +1,36 @@ +{% extends '::base.html.twig' %} + +{% block body -%} +

Status

+ + + + + + + + + + + + + + + + +
Id{{ entity.id }}
Label{{ entity.label }}
Active{{ entity.active }}
+ + +{% endblock %} diff --git a/Tests/Controller/EventTypeControllerTest.php b/Tests/Controller/EventTypeControllerTest.php new file mode 100644 index 000000000..2075dfdbe --- /dev/null +++ b/Tests/Controller/EventTypeControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/{_locale}/admin/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /{_locale}/admin/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_eventtype[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( + 'chill_eventbundle_eventtype[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()); + } + + */ +} diff --git a/Tests/Controller/RoleControllerTest.php b/Tests/Controller/RoleControllerTest.php new file mode 100644 index 000000000..39d21ff7b --- /dev/null +++ b/Tests/Controller/RoleControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/{_locale}/admin/role/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /{_locale}/admin/role/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_role[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( + 'chill_eventbundle_role[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()); + } + + */ +} diff --git a/Tests/Controller/StatusControllerTest.php b/Tests/Controller/StatusControllerTest.php new file mode 100644 index 000000000..fc2c94259 --- /dev/null +++ b/Tests/Controller/StatusControllerTest.php @@ -0,0 +1,55 @@ +request('GET', '/fr/admin/event/status/'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /fr/admin/event/status/"); + $crawler = $client->click($crawler->selectLink('Create a new entry')->link()); + + // Fill in the form and submit it + $form = $crawler->selectButton('Create')->form(array( + 'chill_eventbundle_status[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( + 'chill_eventbundle_status[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()); + } + + */ +}