authorizationChecker = $authorizationChecker; $this->territoryStore = $territoryStore; parent::__construct($translatorAdmin); } public function configureIndex(): array { return [ 'firstname', 'lastname', 'territory', 'nbDream', 'nbRevolt', 'nbProjectBoost', 'nbProjectInspiring', ]; } public function configureFields(): array { $fields = array(); $territoryArray = $this->territoryStore->get(); $fields['firstname'] = TextField::new('firstname'); $fields['lastname'] = TextField::new('lastname'); $fields['email'] = EmailField::new('email'); $fields['territory'] = AssociationField::new('territory')->setFormTypeOption('choices', $territoryArray); $fields['nbDream'] = TextField::new('nbDream'); $fields['nbRevolt'] = TextField::new('nbRevolt'); $fields['nbProjectBoost'] = TextField::new('nbProjectBoost'); $fields['nbProjectInspiring'] = TextField::new('nbProjectInspiring'); $fields['revolt'] = CollectionField::new('revolt') ->setFormTypeOption('entry_type', RevoltType::class) ->setFormTypeOption('by_reference', false) ->setRequired(false); $fields['dream'] = CollectionField::new('dream') ->setFormTypeOption('entry_type', DreamType::class) ->setFormTypeOption('by_reference', false) ->setRequired(false); $fields['projectBoost'] = CollectionField::new('projectBoost') ->setFormTypeOption('entry_type', ProjectBoostType::class) ->setFormTypeOption('by_reference', false) ->setRequired(false); $fields['projectInspiring'] = CollectionField::new('projectinspiring') ->setFormTypeOption('entry_type', ProjectInspiringType::class) ->setFormTypeOption('by_reference', false) ->setRequired(false); $hasAccess = $this->authorizationChecker->isGranted('ROLE_ADMIN'); if ($hasAccess) { $fields['status'] = StatusField::new('status') ->setFormTypeOption('data', 0) ->setFormTypeOption('choices', ['Validé' => 1, 'En attente' => 0]) ->setCustomOption('toggle_label', 'Valider'); } else { $fields['status'] = HiddenField::new('status') ->setFormTypeOption('data', 0); } return $fields; } }