No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

UserFieldDefinition.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  4. use Lc\CaracoleBundle\Context\MerchantContextTrait;
  5. use Lc\CaracoleBundle\Field\AssociationField;
  6. use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
  7. use Lc\CaracoleBundle\Repository\User\GroupUserStore;
  8. use Lc\CaracoleBundle\Solver\Ticket\TicketSolver;
  9. use Lc\SovBundle\Definition\Field\User\UserFieldDefinition as SovUserFieldDefinition;
  10. use Lc\SovBundle\Definition\RolesDefinition;
  11. use Lc\SovBundle\Field\BooleanField;
  12. use Lc\SovBundle\Translation\TranslatorAdmin;
  13. use function Clue\StreamFilter\fun;
  14. class UserFieldDefinition extends SovUserFieldDefinition
  15. {
  16. use MerchantContextTrait;
  17. protected GroupUserStore $groupUserStore;
  18. protected NewsletterStore $newsletterStore;
  19. public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition, GroupUserStore $groupUserStore, NewsletterStore $newsletterStore)
  20. {
  21. parent::__construct($translatorAdmin, $rolesDefinition);
  22. $this->groupUserStore = $groupUserStore;
  23. $this->newsletterStore = $newsletterStore;
  24. }
  25. public function configureForm(): array
  26. {
  27. return [
  28. 'gender',
  29. 'lastname',
  30. 'firstname',
  31. 'email',
  32. 'phone',
  33. 'birthdate',
  34. 'groupUsers',
  35. 'isSaleAlwaysOpen',
  36. 'newsletters',
  37. 'ticketTypesNotification'
  38. ];
  39. }
  40. public function configureFields(): array
  41. {
  42. $groupUsers = $this->groupUserStore->setMerchant($this->merchant)->getAll();
  43. $newsletters = $this->newsletterStore->getAll();
  44. return array_merge(parent::configureFields(),[
  45. 'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'),
  46. 'newsletters' => AssociationField::new('newsletters')
  47. ->setFormTypeOption('choices', $newsletters)
  48. ->setFormTypeOption('choice_label', function ($choice) {
  49. return $choice->getTitle(). '['.$choice->getSection()->getMerchant().']';
  50. })
  51. ->setSortable(true),
  52. 'groupUsers' => AssociationField::new('groupUsers')
  53. ->setFormTypeOption('choices', $groupUsers)
  54. ->setFormTypeOption('choice_label', function ($choice) {
  55. return $choice->getTitle(). '['.$choice->getMerchant().']';
  56. })
  57. ->setSortable(true),
  58. 'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
  59. ->setSortable(true)
  60. ->setFormTypeOption('expanded', false)
  61. ->setFormTypeOption('multiple', true)
  62. ->setChoices($this->translatorAdmin->transChoices(
  63. TicketSolver::getTypeChoices(),
  64. 'Ticket',
  65. 'type'
  66. )),
  67. ]);
  68. }
  69. }