選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

UserFieldDefinition.php 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace Lc\SovBundle\Definition\Field\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  8. use Lc\CaracoleBundle\Field\AssociationField;
  9. use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
  10. use Lc\SovBundle\Definition\RolesDefinition;
  11. use Lc\SovBundle\Solver\Ticket\TicketSolver;
  12. use Lc\SovBundle\Solver\User\UserSolver;
  13. use Lc\SovBundle\Translation\TranslatorAdmin;
  14. class UserFieldDefinition extends AbstractFieldDefinition
  15. {
  16. protected RolesDefinition $rolesDefinition;
  17. public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition)
  18. {
  19. parent::__construct($translatorAdmin);
  20. $this->rolesDefinition = $rolesDefinition;
  21. }
  22. public function configureIndex(): array
  23. {
  24. return [
  25. 'id',
  26. 'gender',
  27. 'lastname',
  28. 'firstname',
  29. 'email',
  30. 'groupUsers'
  31. ];
  32. }
  33. public function configureForm(): array
  34. {
  35. return [
  36. 'id',
  37. 'gender',
  38. 'lastname',
  39. 'firstname',
  40. 'email',
  41. 'phone',
  42. 'birthdate',
  43. 'groupUsers',
  44. 'ticketTypesNotification'
  45. ];
  46. }
  47. public function configurePanels(): array
  48. {
  49. return [];
  50. }
  51. public function configureFields(): array
  52. {
  53. return [
  54. 'id' => IntegerField::new('id')->setSortable(true),
  55. 'gender' => ChoiceField::new('gender')->setChoices(
  56. $this->translatorAdmin->transChoices(UserSolver::getGenderChoices(), 'User', 'gender')
  57. )
  58. ->setFormTypeOption('expanded', true)
  59. ->setFormTypeOption('multiple', false)
  60. ->setSortable(true),
  61. 'lastname' => TextField::new('lastname')->setSortable(true),
  62. 'firstname' => TextField::new('firstname')->setSortable(true),
  63. 'email' => TextField::new('email')->setSortable(true),
  64. 'phone' => TextField::new('phone')->setSortable(true),
  65. 'birthdate' => DateField::new('birthdate')
  66. ->setFormTypeOption('required', false)
  67. ->setSortable(true),
  68. 'groupUsers' => AssociationField::new('groupUsers')->setSortable(true),
  69. 'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
  70. ->setSortable(true)
  71. ->setFormTypeOption('expanded', false)
  72. ->setFormTypeOption('multiple', true)
  73. ->setChoices(
  74. $this->translatorAdmin->transChoices(
  75. TicketSolver::getTypeChoices(),
  76. 'Ticket',
  77. 'type'
  78. )
  79. ),
  80. 'roles' => ChoiceField::new('roles')
  81. ->allowMultipleChoices()
  82. ->autocomplete()
  83. ->setChoices($this->rolesDefinition->getRolesList()),
  84. ];
  85. }
  86. }