diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php deleted file mode 100644 index f27bea0ae..000000000 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityTypeController.php +++ /dev/null @@ -1,178 +0,0 @@ -getDoctrine()->getManager(); - - $entities = $em->getRepository('ChillActivityBundle:ActivityType')->findAll(); - - return $this->render('ChillActivityBundle:ActivityType:index.html.twig', array( - 'entities' => $entities, - )); - } - /** - * Creates a new ActivityType entity. - * - */ - public function createAction(Request $request) - { - $entity = new ActivityType(); - $form = $this->createCreateForm($entity); - $form->handleRequest($request); - - if ($form->isValid()) { - $em = $this->getDoctrine()->getManager(); - $em->persist($entity); - $em->flush(); - - return $this->redirect($this->generateUrl('chill_activity_activitytype_show', array('id' => $entity->getId()))); - } - - return $this->render('ChillActivityBundle:ActivityType:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - )); - } - - /** - * Creates a form to create a ActivityType entity. - * - * @param ActivityType $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(ActivityType $entity) - { - $form = $this->createForm(ActivityTypeType::class, $entity, array( - 'action' => $this->generateUrl('chill_activity_activitytype_create'), - 'method' => 'POST', - )); - - $form->add('submit', SubmitType::class, array('label' => 'Create')); - - return $form; - } - - /** - * Displays a form to create a new ActivityType entity. - * - */ - public function newAction() - { - $entity = new ActivityType(); - $form = $this->createCreateForm($entity); - - return $this->render('ChillActivityBundle:ActivityType:new.html.twig', array( - 'entity' => $entity, - 'form' => $form->createView(), - )); - } - - /** - * Finds and displays a ActivityType entity. - * - */ - public function showAction($id) - { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityType entity.'); - } - - return $this->render('ChillActivityBundle:ActivityType:show.html.twig', array( - 'entity' => $entity, - )); - } - - /** - * Displays a form to edit an existing ActivityType entity. - * - */ - public function editAction($id) - { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityType entity.'); - } - - $editForm = $this->createEditForm($entity); - - return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', array( - 'entity' => $entity, - 'edit_form' => $editForm->createView() - )); - } - - /** - * Creates a form to edit a ActivityType entity. - * - * @param ActivityType $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createEditForm(ActivityType $entity) - { - $form = $this->createForm(ActivityTypeType::class, $entity, array( - 'action' => $this->generateUrl('chill_activity_activitytype_update', array('id' => $entity->getId())), - 'method' => 'PUT', - )); - - $form->add('submit', SubmitType::class, array('label' => 'Update')); - - return $form; - } - /** - * Edits an existing ActivityType entity. - * - */ - public function updateAction(Request $request, $id) - { - $em = $this->getDoctrine()->getManager(); - - $entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id); - - if (!$entity) { - throw $this->createNotFoundException('Unable to find ActivityType entity.'); - } - - $editForm = $this->createEditForm($entity); - $editForm->handleRequest($request); - - if ($editForm->isValid()) { - $em->flush(); - - return $this->redirect($this->generateUrl('chill_activity_activitytype_edit', array('id' => $id))); - } - - return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', array( - 'entity' => $entity, - 'edit_form' => $editForm->createView(), - )); - } -} diff --git a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php index 6abc3ac65..149e83d28 100644 --- a/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php +++ b/src/Bundle/ChillActivityBundle/Controller/AdminActivityTypeCategoryController.php @@ -1,9 +1,7 @@ orderBy('e.id', 'ASC'); + } +} diff --git a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php index 6007a6267..3107c9705 100644 --- a/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php +++ b/src/Bundle/ChillActivityBundle/DependencyInjection/ChillActivityExtension.php @@ -96,6 +96,27 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf { $container->prependExtensionConfig('chill_main', [ 'cruds' => [ + [ + 'class' => \Chill\ActivityBundle\Entity\ActivityType::class, + 'name' => 'activity_type', + 'base_path' => '/admin/activity_type', + 'form_class' => \Chill\ActivityBundle\Form\ActivityTypeType::class, + 'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeController::class, + 'actions' => [ + 'index' => [ + 'template' => '@ChillActivity/ActivityType/index.html.twig', + 'role' => 'ROLE_ADMIN' + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityType/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillActivity/ActivityType/edit.html.twig', + ] + ] + ], [ 'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class, 'name' => 'activity_type_category', diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index a402f584c..f241509ef 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -33,15 +33,7 @@ class ActivityTypeType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'data_class' => 'Chill\ActivityBundle\Entity\ActivityType' + 'data_class' => \Chill\ActivityBundle\Entity\ActivityType::class )); } - - /** - * @return string - */ - public function getBlockPrefix() - { - return 'chill_activitybundle_activitytype'; - } } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig index 99bc71057..dacee767c 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/edit.html.twig @@ -1,40 +1,12 @@ -{# - * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} {% extends "@ChillActivity/Admin/layout_activity.html.twig" %} -{% block admin_content %} -

{{ 'ActivityType edit'|trans }}

- - {{ form_start(edit_form) }} - {{ form_row(edit_form.active) }} - {{ form_row(edit_form.name) }} - - - - - - {{ form_end(edit_form) }} +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block layout_wvm_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig index d9f0cbca6..fd1fd8e29 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/ActivityType/index.html.twig @@ -30,7 +30,7 @@ {% for entity in entities %} - {{ entity.name|localize_translatable_string }} + {{ entity.name|localize_translatable_string }} {%- if entity.active -%} @@ -41,10 +41,7 @@ @@ -55,7 +52,7 @@