|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?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 ?array $newsletterArray = null;
-
- 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();
-
- if(is_null($this->newsletterArray)){
- $this->newsletterArray = $this->newsletterStore
- ->setSection($this->section)
- ->setMerchant($this->merchant)
- ->get();
- }
-
- $fieldArray['newsletter']->setFormTypeOption('choices', $this->newsletterArray);
-
- return $fieldArray;
- }
- }
|