Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

45 lines
1.4KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Definition\Field\Site;
  3. use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
  4. use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
  5. use Lc\CaracoleBundle\Repository\Section\SectionStore;
  6. use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition as SovNewsFieldDefinition;
  7. use Lc\SovBundle\Translation\TranslatorAdmin;
  8. class NewsFieldDefinition extends SovNewsFieldDefinition
  9. {
  10. use FieldDefinitionTrait;
  11. protected SectionStore $sectionStore;
  12. protected NewsletterStore $newsletterStore;
  13. public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore, NewsletterStore $newsletterStore)
  14. {
  15. parent::__construct($translatorAdmin);
  16. $this->sectionStore = $sectionStore;
  17. $this->newsletterStore = $newsletterStore;
  18. }
  19. public function configureIndex(): array
  20. {
  21. return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex());
  22. }
  23. public function configurePanelMain(): array
  24. {
  25. return array_merge(['section'], parent::configurePanelMain());
  26. }
  27. public function configureFields(): array
  28. {
  29. $fieldArray = parent::configureFields();
  30. $newsletterArray = $this->newsletterStore->setSection($this->section)->get();
  31. $fieldArray['newsletter']->setFormTypeOption('choices', $newsletterArray);
  32. return $fieldArray;
  33. }
  34. }