|
- <?php
-
- namespace Lc\SovBundle\Definition\Field\User;
-
-
- use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
- use Lc\CaracoleBundle\Field\AssociationField;
- use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
- use Lc\SovBundle\Definition\RolesDefinition;
- use Lc\SovBundle\Solver\Ticket\TicketSolver;
- use Lc\SovBundle\Solver\User\UserSolver;
- use Lc\SovBundle\Translation\TranslatorAdmin;
-
- class UserFieldDefinition extends AbstractFieldDefinition
- {
- protected RolesDefinition $rolesDefinition;
-
- public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition)
- {
- parent::__construct($translatorAdmin);
-
- $this->rolesDefinition = $rolesDefinition;
- }
-
- public function configureIndex(): array
- {
- return [
- 'id',
- 'gender',
- 'lastname',
- 'firstname',
- 'email',
- 'groupUsers'
- ];
- }
-
- public function configureForm(): array
- {
- return [
- 'id',
- 'gender',
- 'lastname',
- 'firstname',
- 'email',
- 'phone',
- 'birthdate',
- 'groupUsers',
- 'ticketTypesNotification'
- ];
- }
-
- public function configurePanels(): array
- {
- return [];
- }
-
- public function configureFields(): array
- {
- return [
- 'id' => IntegerField::new('id')->setSortable(true),
- 'gender' => ChoiceField::new('gender')->setChoices(
- $this->translatorAdmin->transChoices(UserSolver::getGenderChoices(), 'User', 'gender')
- )
- ->setFormTypeOption('expanded', true)
- ->setFormTypeOption('multiple', false)
- ->setSortable(true),
- 'lastname' => TextField::new('lastname')->setSortable(true),
- 'firstname' => TextField::new('firstname')->setSortable(true),
- 'email' => TextField::new('email')->setSortable(true),
- 'phone' => TextField::new('phone')->setSortable(true),
- 'birthdate' => DateField::new('birthdate')
- ->setFormTypeOption('required', false)
- ->setSortable(true),
- 'groupUsers' => AssociationField::new('groupUsers')->setSortable(true),
- 'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
- ->setSortable(true)
- ->setFormTypeOption('expanded', false)
- ->setFormTypeOption('multiple', true)
- ->setChoices(
- $this->translatorAdmin->transChoices(
- TicketSolver::getTypeChoices(),
- 'Ticket',
- 'type'
- )
- ),
- 'roles' => ChoiceField::new('roles')
- ->allowMultipleChoices()
- ->autocomplete()
- ->setChoices($this->rolesDefinition->getRolesList()),
- ];
- }
-
- }
|