Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

TicketFieldDefinition.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\Ticket;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  4. use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
  5. use Lc\CaracoleBundle\Repository\Section\SectionStore;
  6. use Lc\CaracoleBundle\Solver\Ticket\TicketSolver;
  7. use Lc\SovBundle\Definition\Field\Ticket\TicketFieldDefinition as SovTicketFieldDefinition;
  8. use Lc\SovBundle\Translation\TranslatorAdmin;
  9. class TicketFieldDefinition extends SovTicketFieldDefinition
  10. {
  11. use FieldDefinitionTrait;
  12. protected SectionStore $sectionStore;
  13. public function __construct(
  14. TranslatorAdmin $translatorAdmin,
  15. TicketSolver $ticketSolver,
  16. SectionStore $sectionStore
  17. ) {
  18. parent::__construct($translatorAdmin, $ticketSolver);
  19. $this->sectionStore = $sectionStore;
  20. }
  21. public function configureFields(): array
  22. {
  23. return array_merge(parent::configureFields(), [
  24. 'type' => ChoiceField::new('type')
  25. ->autocomplete()
  26. ->setSortable(true)
  27. ->setChoices(
  28. $this->translatorAdmin->transChoices(
  29. TicketSolver::getTypeChoices(),
  30. 'Ticket',
  31. 'type'
  32. )
  33. ),
  34. ]);
  35. }
  36. public function configureIndex(): array
  37. {
  38. return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex());
  39. }
  40. public function configureForm(): array
  41. {
  42. return array_merge(['section'], parent::configureForm());
  43. }
  44. }