diff --git a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php index 0cff8ee51..34fd9897e 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/Select2MaritalStatusType.php @@ -20,6 +20,9 @@ namespace Chill\PersonBundle\Form\Type; +use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\PersonBundle\Entity\MaritalStatus; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\OptionsResolver; use Chill\MainBundle\Form\Type\DataTransformer\ObjectToIdTransformer; @@ -35,15 +38,13 @@ use Chill\MainBundle\Form\Type\Select2ChoiceType; */ class Select2MaritalStatusType extends AbstractType { - /** @var RequestStack */ - private $requestStack; + private EntityManagerInterface $em; - /** @var ObjectManager */ - private $em; + private TranslatableStringHelper $translatableStringHelper; - public function __construct(RequestStack $requestStack,ObjectManager $em) + public function __construct(TranslatableStringHelper $translatableStringHelper, EntityManagerInterface $em) { - $this->requestStack = $requestStack; + $this->translatableStringHelper = $translatableStringHelper; $this->em = $em; } @@ -63,18 +64,17 @@ class Select2MaritalStatusType extends AbstractType public function configureOptions(OptionsResolver $resolver) { - $locale = $this->requestStack->getCurrentRequest()->getLocale(); $maritalStatuses = $this->em->getRepository('Chill\PersonBundle\Entity\MaritalStatus')->findAll(); $choices = array(); foreach ($maritalStatuses as $ms) { - $choices[$ms->getId()] = $ms->getName()[$locale]; + $choices[$ms->getId()] = $this->translatableStringHelper->localize($ms->getName()); } asort($choices, SORT_STRING | SORT_FLAG_CASE); $resolver->setDefaults(array( - 'class' => 'Chill\PersonBundle\Entity\MaritalStatus', + 'class' => MaritalStatus::class, 'choices' => array_combine(array_values($choices),array_keys($choices)) )); } diff --git a/src/Bundle/ChillPersonBundle/config/services.yaml b/src/Bundle/ChillPersonBundle/config/services.yaml index bf4b8ddd8..43e042e6b 100644 --- a/src/Bundle/ChillPersonBundle/config/services.yaml +++ b/src/Bundle/ChillPersonBundle/config/services.yaml @@ -24,14 +24,6 @@ services: tags: - { name: console.command } - chill.person.form.type.select2maritalstatus: - class: Chill\PersonBundle\Form\Type\Select2MaritalStatusType - arguments: - - "@request_stack" - - "@doctrine.orm.entity_manager" - tags: - - { name: form.type, alias: select2_chill_marital_status } - chill.person.timeline.accompanying_period_opening: class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening arguments: diff --git a/src/Bundle/ChillPersonBundle/config/services/form.yaml b/src/Bundle/ChillPersonBundle/config/services/form.yaml index b61de615d..dacfa41de 100644 --- a/src/Bundle/ChillPersonBundle/config/services/form.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/form.yaml @@ -1,5 +1,10 @@ services: + Chill\PersonBundle\Form\: + autowire: true + autoconfigure: true + resource: '../../Form/' + Chill\PersonBundle\Form\PersonType: arguments: - '%chill_person.person_fields%' @@ -7,14 +12,7 @@ services: tags: - { name: form.type, alias: '@chill.person.form.person_creation' } - Chill\PersonBundle\Form\CreationPersonType: - arguments: - - '@chill.main.form.data_transformer.center_transformer' - - '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper' - tags: - - { name: form.type, alias: '@chill.main.form.person_creation' } - - chill.person.accompanying_period_closing_motive: + Chill\PersonBundle\Form\Type\ClosingMotivePickerType: class: Chill\PersonBundle\Form\Type\ClosingMotivePickerType arguments: $translatableStringHelper: '@Chill\MainBundle\Templating\TranslatableStringHelper' @@ -28,60 +26,3 @@ services: $config: "%chill_person.accompanying_period_fields%" tags: - { name: form.type } - - chill.person.form.type.pick_person: - class: Chill\PersonBundle\Form\Type\PickPersonType - arguments: - - '@Chill\PersonBundle\Repository\PersonRepository' - - "@security.token_storage" - - "@chill.main.security.authorization.helper" - - '@Symfony\Component\Routing\Generator\UrlGeneratorInterface' - - '@Symfony\Component\Translation\TranslatorInterface' - tags: - - { name: form.type } - - Chill\PersonBundle\Form\Type\PersonAltNameType: - arguments: - $configHelper: '@Chill\PersonBundle\Config\ConfigPersonAltNamesHelper' - $translatableStringHelper: '@chill.main.helper.translatable_string' - tags: - - { name: form.type } - - Chill\PersonBundle\Form\Type\PersonPhoneType: - arguments: - $phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper' - $em: '@Doctrine\ORM\EntityManagerInterface' - tags: - - { name: form.type } - - Chill\PersonBundle\Form\SocialWork\SocialIssueType: - arguments: - $translatableStringHelper: '@chill.main.helper.translatable_string' - tags: - - { name: form.type } - - Chill\PersonBundle\Form\SocialWork\SocialActionType: - arguments: - $translatableStringHelper: '@chill.main.helper.translatable_string' - tags: - - { name: form.type } - - Chill\PersonBundle\Form\SocialWork\EvaluationType: - arguments: - $translatableStringHelper: '@chill.main.helper.translatable_string' - tags: - - { name: form.type } - - - Chill\PersonBundle\Form\SocialWork\GoalType: - arguments: - $translatableStringHelper: '@chill.main.helper.translatable_string' - tags: - - { name: form.type } - - - Chill\PersonBundle\Form\SocialWork\ResultType: - arguments: - $translatableStringHelper: '@chill.main.helper.translatable_string' - tags: - - { name: form.type }