return $this->get(SectionResolver::class)->getCurrent(); | return $this->get(SectionResolver::class)->getCurrent(); | ||||
} | } | ||||
public function isOutOfSection() | |||||
{ | |||||
return is_null($this->getSectionCurrent()); | |||||
} | |||||
public function getSectionCurrentSlug(): string | public function getSectionCurrentSlug(): string | ||||
{ | { | ||||
return $this->getSectionCurrent()->getSlug(); | return $this->getSectionCurrent()->getSlug(); |
namespace Lc\CaracoleBundle\Controller\Product; | namespace Lc\CaracoleBundle\Controller\Product; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | ||||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | use Lc\CaracoleBundle\Controller\AbstractAdminController; | ||||
use Lc\CaracoleBundle\Definition\ActionDefinition; | |||||
use Lc\SovBundle\Field\CKEditorField; | use Lc\SovBundle\Field\CKEditorField; | ||||
use Lc\SovBundle\Field\StatusField; | use Lc\SovBundle\Field\StatusField; | ||||
use Lc\SovBundle\Field\ToggleField; | use Lc\SovBundle\Field\ToggleField; | ||||
->getFields($pageName); | ->getFields($pageName); | ||||
} | } | ||||
public function configureActions(Actions $actions): Actions | |||||
{ | |||||
$actions = parent::configureActions($actions); | |||||
if(!$this->getSectionCurrent()) { | |||||
$actions->disable(ActionDefinition::NEW); | |||||
} | |||||
return $actions; | |||||
} | |||||
} | } |
return array_merge(parent::configureFieldsBase(), [ | return array_merge(parent::configureFieldsBase(), [ | ||||
'section' => AssociationField::new('section') | 'section' => AssociationField::new('section') | ||||
->setRequired(true) | |||||
->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | ->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | ||||
->setFormTypeOption('choices', $sectionArray) | ->setFormTypeOption('choices', $sectionArray) | ||||
]); | ]); |
public function __construct( | public function __construct( | ||||
TranslatorAdmin $translatorAdmin, | TranslatorAdmin $translatorAdmin, | ||||
TicketSolver $ticketSolver, | |||||
SectionStore $sectionStore | SectionStore $sectionStore | ||||
) { | ) { | ||||
parent::__construct($translatorAdmin); | |||||
parent::__construct($translatorAdmin, $ticketSolver); | |||||
$this->sectionStore = $sectionStore; | $this->sectionStore = $sectionStore; | ||||
} | } | ||||
public function configureFields(): array | public function configureFields(): array | ||||
{ | { | ||||
return array_merge(parent::configureFields(), [ | return array_merge(parent::configureFields(), [ |
<?php | |||||
namespace Lc\CaracoleBundle\EventSubscriber; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||||
use Symfony\Component\HttpKernel\KernelEvents; | |||||
class OpeningEventSubscriber implements EventSubscriberInterface | |||||
{ | |||||
protected EntityManagerInterface $entityManager; | |||||
public function __construct( | |||||
EntityManagerInterface $entityManager | |||||
) { | |||||
$this->entityManager = $entityManager; | |||||
} | |||||
public static function getSubscribedEvents() | |||||
{ | |||||
return [ | |||||
KernelEvents::CONTROLLER => ['initOpenings'] | |||||
]; | |||||
} | |||||
public function initOpenings() | |||||
{ | |||||
} | |||||
} |
{ | { | ||||
$merchant = new Merchant(); | $merchant = new Merchant(); | ||||
$merchant->setStatus(1); | |||||
return $merchant; | return $merchant; | ||||
} | } | ||||
$newsletter = parent::create(); | $newsletter = parent::create(); | ||||
$newsletter->setSection($this->section); | $newsletter->setSection($this->section); | ||||
$newsletter->setStatus(1); | |||||
return $newsletter; | return $newsletter; | ||||
} | } |
$pointSale = new PointSale(); | $pointSale = new PointSale(); | ||||
$pointSale->addMerchant($merchant); | $pointSale->addMerchant($merchant); | ||||
$pointSale->setStatus(1); | |||||
return $pointSale; | return $pointSale; | ||||
} | } |
class ProductCategoryFactory extends AbstractFactory | class ProductCategoryFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(SectionInterface $section): ProductCategoryInterface | public function create(SectionInterface $section): ProductCategoryInterface | ||||
{ | { | ||||
$productCategory = new ProductCategory(); | $productCategory = new ProductCategory(); | ||||
$productCategory->setSection($section); | $productCategory->setSection($section); | ||||
$productCategory->setSaleStatus(true); | |||||
$productCategory->setStatus(1); | |||||
return $productCategory; | return $productCategory; | ||||
} | } | ||||
} | } |
{ | { | ||||
$productFamily = new ProductFamily(); | $productFamily = new ProductFamily(); | ||||
$productFamily->setSaleStatus(true); | |||||
$productFamily->setStatus(1); | |||||
$productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory(); | $productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory(); | ||||
foreach($merchant->getSections() as $section) { | foreach($merchant->getSections() as $section) { |
$reductionCart = new ReductionCart(); | $reductionCart = new ReductionCart(); | ||||
$reductionCart->setSection($section); | $reductionCart->setSection($section); | ||||
$reductionCart->setStatus(1); | |||||
return $reductionCart; | return $reductionCart; | ||||
} | } |
$reductionCatalog = new ReductionCatalog(); | $reductionCatalog = new ReductionCatalog(); | ||||
$reductionCatalog->setSection($section); | $reductionCatalog->setSection($section); | ||||
$reductionCatalog->setStatus(1); | |||||
return $reductionCatalog; | return $reductionCatalog; | ||||
} | } |
$page = parent::create(); | $page = parent::create(); | ||||
$page->setMerchant($this->merchant); | $page->setMerchant($this->merchant); | ||||
$page->setSection($this->section); | |||||
if(!is_null($this->section)) { | |||||
$page->setSection($this->section); | |||||
} | |||||
return $page; | return $page; | ||||
} | } |
interface ProductCategoryInterface | interface ProductCategoryInterface | ||||
{ | { | ||||
public function getSection(): SectionInterface; | |||||
public function getSection(): ?SectionInterface; | |||||
public function setSection(SectionInterface $section): ProductCategoryModel; | public function setSection(SectionInterface $section): ProductCategoryModel; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSection(): SectionInterface | |||||
public function getSection(): ?SectionInterface | |||||
{ | { | ||||
return $this->section; | return $this->section; | ||||
} | } |
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterBySection($this->section); | |||||
$this->addFilterBySectionOptionnal($query); | |||||
return $query; | return $query; | ||||
} | } | ||||
{ | { | ||||
return $query; | return $query; | ||||
} | } | ||||
} | } |
} | } | ||||
} // front | } // front | ||||
else { | else { | ||||
dump('front'); | |||||
dump($requestAttributesArray); | |||||
if($this->section === null) { | if($this->section === null) { | ||||
$merchantCurrent = $this->merchantResolver->getCurrent(); | $merchantCurrent = $this->merchantResolver->getCurrent(); | ||||
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); | $sectionStore = $this->sectionStore->setMerchant($merchantCurrent); |
class TicketSolver extends SovTicketSolver | class TicketSolver extends SovTicketSolver | ||||
{ | { | ||||
public static function getTypeChoices(): array | |||||
public function getTypeChoices(): array | |||||
{ | { | ||||
$choices = parent::getTypeChoices(); | $choices = parent::getTypeChoices(); | ||||
$choicesProduct = [ | $choicesProduct = [ |