|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
-
- namespace Lc\CaracoleBundle\Definition\Field\Site;
-
- use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait;
- use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
- use Lc\CaracoleBundle\Repository\Section\SectionStore;
- use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition as SovNewsFieldDefinition;
- use Lc\SovBundle\Translation\TranslatorAdmin;
-
- class NewsFieldDefinition extends SovNewsFieldDefinition
- {
- use FieldDefinitionTrait;
-
- protected SectionStore $sectionStore;
- protected NewsletterStore $newsletterStore;
-
- public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore, NewsletterStore $newsletterStore)
- {
- parent::__construct($translatorAdmin);
- $this->sectionStore = $sectionStore;
- $this->newsletterStore = $newsletterStore;
- }
-
- public function configureIndex(): array
- {
- return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex());
- }
-
- public function configurePanelMain(): array
- {
- return array_merge(['section'], parent::configurePanelMain());
- }
-
- public function configureFields(): array
- {
- $fieldArray = parent::configureFields();
-
- $newsletterArray = $this->newsletterStore->setSection($this->section)->get();
- $fieldArray['newsletter']->setFormTypeOption('choices', $newsletterArray);
-
- return $fieldArray;
- }
- }
|