mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,144 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\AMLI\FamilyMembersBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\PersonBundle\Form\Type\GenderType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||
use Chill\AMLI\FamilyMembersBundle\Config\ConfigRepository;
|
||||
use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\AMLI\AssignmentBundle\Entity\AbstractDiagnosticNIAssignment;
|
||||
use Chill\AMLI\FamilyMembersBundle\Entity\AbstractFamilyMember;
|
||||
use Chill\PersonBundle\Form\Type\GenderType;
|
||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FamilyMemberType extends AbstractType
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var ConfigRepository
|
||||
*/
|
||||
private $configRepository;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
|
||||
|
||||
public function __construct(
|
||||
ConfigRepository $configRepository,
|
||||
ConfigRepository $configRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->configRepository = $configRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
$builder
|
||||
->add('lastname', TextType::class, [
|
||||
'label' => 'Last name'
|
||||
'label' => 'Last name',
|
||||
])
|
||||
->add('firstname', TextType::class, [
|
||||
'label' => 'First name'
|
||||
'label' => 'First name',
|
||||
])
|
||||
->add('gender', GenderType::class)
|
||||
->add('birthdate', ChillDateType::class, [
|
||||
'required' => false
|
||||
'required' => false,
|
||||
])
|
||||
->add('link', ChoiceType::class, [
|
||||
'choices' => $this->buildChoices($this->configRepository->getLinksLabels()),
|
||||
'placeholder' => 'Choose a link',
|
||||
'label' => 'Relationship'
|
||||
'label' => 'Relationship',
|
||||
])
|
||||
->add('maritalStatus', Select2MaritalStatusType::class, [
|
||||
'required' => false
|
||||
])
|
||||
;
|
||||
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
if ($this->configRepository->hasProfessionalSituation()) {
|
||||
$builder
|
||||
->add('professionnalSituation', ChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => $this->buildChoices(
|
||||
$this->configRepository->getProfessionalSituationsLabels()
|
||||
)
|
||||
]);
|
||||
->add('professionnalSituation', ChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => $this->buildChoices(
|
||||
$this->configRepository->getProfessionalSituationsLabels()
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if ($this->configRepository->hasProfessionalSituation()) {
|
||||
$builder
|
||||
->add('familialSituation', ChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => $this->buildChoices(
|
||||
$this->configRepository->getFamilialSituationsLabels()
|
||||
)
|
||||
]);
|
||||
->add('familialSituation', ChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => $this->buildChoices(
|
||||
$this->configRepository->getFamilialSituationsLabels()
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if ($options['show_start_date']) {
|
||||
$builder
|
||||
->add('startDate', ChillDateType::class, [
|
||||
'label' => 'Arrival date in the family'
|
||||
'label' => 'Arrival date in the family',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if ($options['show_end_date']) {
|
||||
$builder
|
||||
->add('endDate', ChillDateType::class, [
|
||||
'required' => false,
|
||||
'label' => 'Departure date of the family'
|
||||
'label' => 'Departure date of the family',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
$resolver->setDefaults([
|
||||
'data_class' => FamilyMember::class,
|
||||
'show_start_date' => true,
|
||||
'show_end_date' => true,
|
||||
));
|
||||
|
||||
]);
|
||||
|
||||
$resolver
|
||||
->setAllowedTypes('show_start_date', 'boolean')
|
||||
->setAllowedTypes('show_end_date', 'boolean')
|
||||
;
|
||||
}
|
||||
|
||||
private function buildChoices($els)
|
||||
{
|
||||
$links = $this->configRepository
|
||||
->getLinksLabels();
|
||||
$choices = [];
|
||||
|
||||
// rewrite labels to filter in language
|
||||
foreach ($els as $key => $labels) {
|
||||
$choices[$this->translatableStringHelper->localize($labels)] = $key;
|
||||
}
|
||||
|
||||
return $choices;
|
||||
->setAllowedTypes('show_end_date', 'boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'chill_amli_familymembersbundle_familymember';
|
||||
}
|
||||
|
||||
private function buildChoices($els)
|
||||
{
|
||||
$links = $this->configRepository
|
||||
->getLinksLabels();
|
||||
$choices = [];
|
||||
|
||||
// rewrite labels to filter in language
|
||||
foreach ($els as $key => $labels) {
|
||||
$choices[$this->translatableStringHelper->localize($labels)] = $key;
|
||||
}
|
||||
|
||||
return $choices;
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,18 @@
|
||||
<?php
|
||||
/*
|
||||
*/
|
||||
namespace Chill\AMLI\FamilyMembersBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\AMLI\FamilyMembersBundle\Form;
|
||||
|
||||
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FamilyMembersType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
@@ -21,15 +21,15 @@ class FamilyMembersType extends AbstractType
|
||||
'entry_type' => FamilyMemberType::class,
|
||||
'entry_options' => [
|
||||
'show_start_date' => true,
|
||||
'show_end_date' => true
|
||||
'show_end_date' => true,
|
||||
],
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'button_add_label' => 'Ajouter un membre',
|
||||
'button_remove_label' => 'Enlever ce membre'
|
||||
'button_remove_label' => 'Enlever ce membre',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return ChillCollectionType::class;
|
||||
|
Reference in New Issue
Block a user