mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
take into account form_show_centers parameters into thirdparty form type
This commit is contained in:
@@ -18,6 +18,7 @@ use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
@@ -46,18 +47,22 @@ class ThirdPartyType extends AbstractType
|
||||
|
||||
protected EntityManagerInterface $om;
|
||||
|
||||
private bool $askCenter;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
ThirdPartyTypeManager $typesManager,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
EntityManagerInterface $om
|
||||
EntityManagerInterface $om,
|
||||
ParameterBagInterface $parameterBag
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->typesManager = $typesManager;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->om = $om;
|
||||
$this->askCenter = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,16 +83,19 @@ class ThirdPartyType extends AbstractType
|
||||
])
|
||||
->add('comment', ChillTextareaType::class, [
|
||||
'required' => false
|
||||
])
|
||||
->add('centers', PickCenterType::class, [
|
||||
'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ?
|
||||
ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
|
||||
'choice_options' => [
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2']
|
||||
]
|
||||
])
|
||||
;
|
||||
]);
|
||||
|
||||
if ($this->askCenter) {
|
||||
$builder
|
||||
->add('centers', PickCenterType::class, [
|
||||
'role' => (\array_key_exists('data', $options) && $this->om->contains($options['data'])) ?
|
||||
ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
|
||||
'choice_options' => [
|
||||
'multiple' => true,
|
||||
'attr' => ['class' => 'select2']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
// Contact Person ThirdParty (child)
|
||||
if (ThirdParty::KIND_CONTACT === $options['kind'] || ThirdParty::KIND_CHILD === $options['kind']) {
|
||||
|
Reference in New Issue
Block a user