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

52 行
1.7KB

  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. }