diff --git a/Form/ActivityType.php b/Form/ActivityType.php index 7cf7cdc52..9f754dce0 100644 --- a/Form/ActivityType.php +++ b/Form/ActivityType.php @@ -81,9 +81,9 @@ class ActivityType extends AbstractType ) )) ->add('user') - //->add('scope') - //->add('reason') - //->add('type') + ->add('scope') + ->add('reason', 'translatable_activity_reason') + ->add('type', 'translatable_activity_type') //->add('person') ; diff --git a/Form/Type/TranslatableActivityReason.php b/Form/Type/TranslatableActivityReason.php new file mode 100644 index 000000000..776dd0ee2 --- /dev/null +++ b/Form/Type/TranslatableActivityReason.php @@ -0,0 +1,66 @@ +, + * + * 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 . + */ + +namespace Chill\ActivityBundle\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\HttpFoundation\RequestStack; + +/** + * Description of TranslatableActivityReason + * + * @author Champs-Libres Coop + */ +class TranslatableActivityReason extends AbstractType +{ + /** + * @var RequestStack + */ + private $requestStack; + + public function __construct(RequestStack $requestStack) + { + $this->requestStack = $requestStack; + } + + public function getName() + { + return 'translatable_activity_reason'; + } + + public function getParent() + { + return 'entity'; + } + + public function configureOptions(OptionsResolver $resolver) + { + $locale = $this->requestStack->getCurrentRequest()->getLocale(); + $resolver->setDefaults( + array( + 'class' => 'ChillActivityBundle:ActivityReason', + 'property' => 'name['.$locale.']' + ) + ); + } +} diff --git a/Form/Type/TranslatableActivityType.php b/Form/Type/TranslatableActivityType.php new file mode 100644 index 000000000..4ce59ae82 --- /dev/null +++ b/Form/Type/TranslatableActivityType.php @@ -0,0 +1,66 @@ +, + * + * 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 . + */ + +namespace Chill\ActivityBundle\Form\Type; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\HttpFoundation\RequestStack; + +/** + * Description of TranslatableActivityType + * + * @author Champs-Libres Coop + */ +class TranslatableActivityType extends AbstractType +{ + /** + * @var RequestStack + */ + private $requestStack; + + public function __construct(RequestStack $requestStack) + { + $this->requestStack = $requestStack; + } + + public function getName() + { + return 'translatable_activity_type'; + } + + public function getParent() + { + return 'entity'; + } + + public function configureOptions(OptionsResolver $resolver) + { + $locale = $this->requestStack->getCurrentRequest()->getLocale(); + $resolver->setDefaults( + array( + 'class' => 'ChillActivityBundle:ActivityType', + 'property' => 'name['.$locale.']' + ) + ); + } +} diff --git a/Resources/config/services.yml b/Resources/config/services.yml index a06eae7d3..81d68773c 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -6,6 +6,20 @@ services: tags: - { name: form.type, alias: translatable_activity_reason_category } + chill.activity.form.type.translatableactivityreason: + class: Chill\ActivityBundle\Form\Type\TranslatableActivityReason + arguments: + - "@request_stack" + tags: + - { name: form.type, alias: translatable_activity_reason } + + chill.activity.form.type.translatableactivitytype: + class: Chill\ActivityBundle\Form\Type\TranslatableActivityType + arguments: + - "@request_stack" + tags: + - { name: form.type, alias: translatable_activity_type } + chill.activity.form.type.activity: class: Chill\ActivityBundle\Form\ActivityType arguments: