diff --git a/Controller/EventTypeController.php b/Controller/EventTypeController.php index cbe28999b..760594600 100644 --- a/Controller/EventTypeController.php +++ b/Controller/EventTypeController.php @@ -44,7 +44,8 @@ class EventTypeController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_eventtype_admin_show', + array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:EventType:new.html.twig', array( @@ -63,7 +64,7 @@ class EventTypeController extends Controller private function createCreateForm(EventType $entity) { $form = $this->createForm(new EventTypeType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_create'), + 'action' => $this->generateUrl('chill_eventtype_admin_create'), 'method' => 'POST', )); @@ -143,7 +144,8 @@ class EventTypeController extends Controller private function createEditForm(EventType $entity) { $form = $this->createForm(new EventTypeType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_update', array('id' => $entity->getId())), + 'action' => $this->generateUrl('chill_eventtype_admin_update', + array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +174,8 @@ class EventTypeController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_eventtype_admin_edit', + array('id' => $id))); } return $this->render('ChillEventBundle:EventType:edit.html.twig', array( @@ -202,7 +205,7 @@ class EventTypeController extends Controller $em->flush(); } - return $this->redirect($this->generateUrl('{_locale}_admin')); + return $this->redirect($this->generateUrl('chill_eventtype_admin')); } /** @@ -215,7 +218,8 @@ class EventTypeController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('{_locale}_admin_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_eventtype_admin_delete', + array('id' => $id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Controller/RoleController.php b/Controller/RoleController.php index 3834e89a9..b1c560292 100644 --- a/Controller/RoleController.php +++ b/Controller/RoleController.php @@ -44,7 +44,8 @@ class RoleController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_role_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_event_admin_role_show', + array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:Role:new.html.twig', array( @@ -62,8 +63,8 @@ class RoleController extends Controller */ private function createCreateForm(Role $entity) { - $form = $this->createForm(new RoleType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_role_create'), + $form = $this->createForm($this->get('chill.event.form.role_type'), $entity, array( + 'action' => $this->generateUrl('chill_event_admin_role_create'), 'method' => 'POST', )); @@ -142,8 +143,9 @@ class RoleController extends Controller */ private function createEditForm(Role $entity) { - $form = $this->createForm(new RoleType(), $entity, array( - 'action' => $this->generateUrl('{_locale}_admin_role_update', array('id' => $entity->getId())), + $form = $this->createForm($this->get('chill.event.form.role_type'), $entity, array( + 'action' => $this->generateUrl('chill_event_admin_role_update', + array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +174,8 @@ class RoleController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('{_locale}_admin_role_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_event_admin_role_edit', + array('id' => $id))); } return $this->render('ChillEventBundle:Role:edit.html.twig', array( @@ -202,7 +205,7 @@ class RoleController extends Controller $em->flush(); } - return $this->redirect($this->generateUrl('{_locale}_admin_role')); + return $this->redirect($this->generateUrl('chill_event_admin_role')); } /** @@ -215,7 +218,7 @@ class RoleController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('{_locale}_admin_role_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_event_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 index e0a57ba51..211153b94 100644 --- a/Controller/StatusController.php +++ b/Controller/StatusController.php @@ -44,7 +44,7 @@ class StatusController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('fr_admin_event_status_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_event_admin_status_show', array('id' => $entity->getId()))); } return $this->render('ChillEventBundle:Status:new.html.twig', array( @@ -63,7 +63,7 @@ class StatusController extends Controller private function createCreateForm(Status $entity) { $form = $this->createForm(new StatusType(), $entity, array( - 'action' => $this->generateUrl('fr_admin_event_status_create'), + 'action' => $this->generateUrl('chill_event_admin_status_create'), 'method' => 'POST', )); @@ -143,7 +143,7 @@ class StatusController extends Controller private function createEditForm(Status $entity) { $form = $this->createForm(new StatusType(), $entity, array( - 'action' => $this->generateUrl('fr_admin_event_status_update', array('id' => $entity->getId())), + 'action' => $this->generateUrl('chill_event_admin_status_update', array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +172,7 @@ class StatusController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('fr_admin_event_status_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_event_admin_status_edit', array('id' => $id))); } return $this->render('ChillEventBundle:Status:edit.html.twig', array( @@ -202,7 +202,7 @@ class StatusController extends Controller $em->flush(); } - return $this->redirect($this->generateUrl('fr_admin_event_status')); + return $this->redirect($this->generateUrl('chill_event_admin_status')); } /** @@ -215,7 +215,7 @@ class StatusController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('fr_admin_event_status_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_event_admin_status_delete', array('id' => $id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Form/EventTypeType.php b/Form/EventTypeType.php index 9616f9f59..b72a9f186 100644 --- a/Form/EventTypeType.php +++ b/Form/EventTypeType.php @@ -5,6 +5,7 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; class EventTypeType extends AbstractType { @@ -15,7 +16,7 @@ class EventTypeType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name') + ->add('name', TranslatableStringFormType::class) ->add('active') ; } diff --git a/Form/RoleType.php b/Form/RoleType.php index 4f8fb3c53..d3483e917 100644 --- a/Form/RoleType.php +++ b/Form/RoleType.php @@ -5,9 +5,23 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Chill\EventBundle\Entity\EventType; class RoleType extends AbstractType { + /** + * + * @var TranslatableStringHelper + */ + protected $translatableStringHelper; + + public function __construct(TranslatableStringHelper $translatableStringHelper) { + $this->translatableStringHelper = $translatableStringHelper; + } + /** * @param FormBuilderInterface $builder * @param array $options @@ -15,9 +29,14 @@ class RoleType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name') + ->add('name', TranslatableStringFormType::class) ->add('active') - ->add('type') + ->add('type', EntityType::class, array( + 'class' => EventType::class, + 'choice_label' => function (EventType $e) { + return $this->translatableStringHelper->localize($e->getName()); + } + )) ; } diff --git a/Form/StatusType.php b/Form/StatusType.php index 1bef97168..d02b21781 100644 --- a/Form/StatusType.php +++ b/Form/StatusType.php @@ -5,6 +5,8 @@ namespace Chill\EventBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Chill\MainBundle\Form\Type\TranslatableStringFormType; +use Chill\EventBundle\Form\Type\PickEventType; class StatusType extends AbstractType { @@ -15,9 +17,9 @@ class StatusType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name') + ->add('name', TranslatableStringFormType::class) ->add('active') - ->add('type') + ->add('type', PickEventType::class) ; } diff --git a/Resources/config/routing/eventtype.yml b/Resources/config/routing/eventtype.yml index cdf54fe85..305c27af8 100644 --- a/Resources/config/routing/eventtype.yml +++ b/Resources/config/routing/eventtype.yml @@ -1,30 +1,30 @@ -chill_event_admin: +chill_eventtype_admin: path: / defaults: { _controller: "ChillEventBundle:EventType:index" } -chill_event_admin_show: +chill_eventtype_admin_show: path: /{id}/show defaults: { _controller: "ChillEventBundle:EventType:show" } -chill_event_admin_new: +chill_eventtype_admin_new: path: /new defaults: { _controller: "ChillEventBundle:EventType:new" } -chill_event_admin_create: +chill_eventtype_admin_create: path: /create defaults: { _controller: "ChillEventBundle:EventType:create" } methods: POST -chill_event_admin_edit: +chill_eventtype_admin_edit: path: /{id}/edit defaults: { _controller: "ChillEventBundle:EventType:edit" } -chill_event_admin_update: +chill_eventtype_admin_update: path: /{id}/update defaults: { _controller: "ChillEventBundle:EventType:update" } methods: [POST, PUT] -chill_event_admin_delete: +chill_eventtype_admin_delete: path: /{id}/delete defaults: { _controller: "ChillEventBundle:EventType:delete" } methods: [POST, DELETE] diff --git a/Resources/config/routing/status.yml b/Resources/config/routing/status.yml index 396f72c39..383a704ff 100644 --- a/Resources/config/routing/status.yml +++ b/Resources/config/routing/status.yml @@ -1,30 +1,30 @@ -fr_admin_event_status: +chill_event_admin_status: path: / defaults: { _controller: "ChillEventBundle:Status:index" } -fr_admin_event_status_show: +chill_event_admin_status_show: path: /{id}/show defaults: { _controller: "ChillEventBundle:Status:show" } -fr_admin_event_status_new: +chill_event_admin_status_new: path: /new defaults: { _controller: "ChillEventBundle:Status:new" } -fr_admin_event_status_create: +chill_event_admin_status_create: path: /create defaults: { _controller: "ChillEventBundle:Status:create" } methods: POST -fr_admin_event_status_edit: +chill_event_admin_status_edit: path: /{id}/edit defaults: { _controller: "ChillEventBundle:Status:edit" } -fr_admin_event_status_update: +chill_event_admin_status_update: path: /{id}/update defaults: { _controller: "ChillEventBundle:Status:update" } methods: [POST, PUT] -fr_admin_event_status_delete: +chill_event_admin_status_delete: path: /{id}/delete defaults: { _controller: "ChillEventBundle:Status:delete" } methods: [POST, DELETE] diff --git a/Resources/config/services/forms.yml b/Resources/config/services/forms.yml index b587bac49..90981d31b 100644 --- a/Resources/config/services/forms.yml +++ b/Resources/config/services/forms.yml @@ -39,3 +39,10 @@ services: - "@chill_event.repository.status" tags: - { name: form.type } + + chill.event.form.role_type: + class: Chill\EventBundle\Form\RoleType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type } diff --git a/Resources/views/EventType/edit.html.twig b/Resources/views/EventType/edit.html.twig index 5849fa686..92bf5a236 100644 --- a/Resources/views/EventType/edit.html.twig +++ b/Resources/views/EventType/edit.html.twig @@ -7,7 +7,7 @@