Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

3 роки тому
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\User\UserSolver;
  12. use Lc\SovBundle\Translation\TranslatorAdmin;
  13. class UserFieldDefinition extends AbstractFieldDefinition
  14. {
  15. protected RolesDefinition $rolesDefinition;
  16. public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition)
  17. {
  18. parent::__construct($translatorAdmin);
  19. $this->rolesDefinition = $rolesDefinition;
  20. }
  21. public function configureFieldsIndex(): array
  22. {
  23. return [
  24. 'id',
  25. 'gender',
  26. 'lastname',
  27. 'firstname',
  28. 'email',
  29. 'groupUsers'
  30. ];
  31. }
  32. public function configureFieldsForm(): array
  33. {
  34. return [
  35. 'id',
  36. 'gender',
  37. 'lastname',
  38. 'firstname',
  39. 'email',
  40. 'phone',
  41. 'birthdate',
  42. 'groupUsers'
  43. ];
  44. }
  45. public function configurePanels(): array
  46. {
  47. return [];
  48. }
  49. public function configureFields(): array
  50. {
  51. return [
  52. 'id' => IntegerField::new('id')->onlyOnIndex()->setSortable(true),
  53. 'gender' => ChoiceField::new('gender')->setChoices(
  54. $this->translatorAdmin->transChoices(UserSolver::getGenderChoices(), 'User', 'gender')
  55. )
  56. ->setFormTypeOption('expanded', true)
  57. ->setFormTypeOption('multiple', false)
  58. ->setSortable(true),
  59. 'lastname' => TextField::new('lastname')->setSortable(true),
  60. 'firstname' => TextField::new('firstname')->setSortable(true),
  61. 'email' => TextField::new('email')->setSortable(true),
  62. 'phone' => TextField::new('phone')->setSortable(true),
  63. 'birthdate' => DateField::new('birthdate')->setSortable(true),
  64. 'groupUsers' => AssociationField::new('groupUsers')->setSortable(true),
  65. 'roles' => ChoiceField::new('roles')
  66. ->allowMultipleChoices()
  67. ->autocomplete()
  68. ->setChoices($this->rolesDefinition->getRolesList()),
  69. ];
  70. }
  71. }