You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NewsFieldDefinition.php 1.4KB

пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
пре 2 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. }