Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

UserFieldDefinition.php 4.0KB

vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\User;
  3. use App\Entity\User\GroupUser;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
  6. use Lc\CaracoleBundle\Context\MerchantContextTrait;
  7. use Lc\CaracoleBundle\Field\AssociationField;
  8. use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
  9. use Lc\CaracoleBundle\Repository\User\GroupUserStore;
  10. use Lc\CaracoleBundle\Solver\Ticket\TicketSolver;
  11. use Lc\SovBundle\Definition\Field\User\UserFieldDefinition as SovUserFieldDefinition;
  12. use Lc\SovBundle\Definition\RolesDefinition;
  13. use Lc\SovBundle\Field\BooleanField;
  14. use Lc\SovBundle\Translation\TranslatorAdmin;
  15. use function Clue\StreamFilter\fun;
  16. class UserFieldDefinition extends SovUserFieldDefinition
  17. {
  18. use MerchantContextTrait;
  19. protected GroupUserStore $groupUserStore;
  20. protected NewsletterStore $newsletterStore;
  21. public function __construct(
  22. TranslatorAdmin $translatorAdmin,
  23. RolesDefinition $rolesDefinition,
  24. GroupUserStore $groupUserStore,
  25. NewsletterStore $newsletterStore
  26. ) {
  27. parent::__construct($translatorAdmin, $rolesDefinition);
  28. $this->groupUserStore = $groupUserStore;
  29. $this->newsletterStore = $newsletterStore;
  30. }
  31. public function configureIndex(): array
  32. {
  33. return [
  34. 'id',
  35. 'gender',
  36. 'lastname',
  37. 'firstname',
  38. 'email',
  39. 'groupUsers',
  40. 'birthdate',
  41. 'countOrder',
  42. 'totalSpent',
  43. 'isSaleAlwaysOpen',
  44. ];
  45. }
  46. public function configureForm(): array
  47. {
  48. return [
  49. 'gender',
  50. 'lastname',
  51. 'firstname',
  52. 'email',
  53. 'phone',
  54. 'birthdate',
  55. 'groupUsers',
  56. 'isSaleAlwaysOpen',
  57. 'newsletters',
  58. 'ticketTypesNotification',
  59. ];
  60. }
  61. public function configureFields(): array
  62. {
  63. $groupUsers = $this->groupUserStore->setMerchant($this->merchant)->getAll();
  64. $newsletters = $this->newsletterStore->getAll();
  65. return array_merge(parent::configureFields(), [
  66. 'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'),
  67. 'newsletters' => AssociationField::new('newsletters')
  68. ->setFormTypeOption('choices', $newsletters)
  69. ->setFormTypeOption('choice_label', function ($choice) {
  70. return $choice->getTitle() . '[' . $choice->getSection()->getMerchant() . ']';
  71. })
  72. ->setSortable(true),
  73. 'groupUsers' => AssociationField::new('groupUsers')
  74. ->setFormTypeOption('choices', $groupUsers)
  75. ->setCustomOption('class', GroupUser::class)
  76. ->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig')
  77. ->setFormTypeOption('choice_label', function ($choice) {
  78. return $choice->getTitle() . '[' . $choice->getMerchant() . ']';
  79. })
  80. ->setSortable(false),
  81. 'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
  82. ->setSortable(true)
  83. ->setFormTypeOption('expanded', false)
  84. ->setFormTypeOption('multiple', true)
  85. ->setChoices(
  86. $this->translatorAdmin->transChoices(
  87. TicketSolver::getTypeChoices(),
  88. 'Ticket',
  89. 'type'
  90. )
  91. ),
  92. 'countOrder' => NumberField::new('countOrder')
  93. ->setFormTypeOption('mapped', false)
  94. ->setCustomOption('filter', false)
  95. ->setTemplatePath('@LcCaracole/admin/user/field/count_order.html.twig'),
  96. 'totalSpent' => NumberField::new('totalSpent')
  97. ->setFormTypeOption('mapped', false)
  98. ->setCustomOption('filter', false)
  99. ->setTemplatePath('@LcCaracole/admin/user/field/total_spent.html.twig'),
  100. ]);
  101. }
  102. }