@@ -154,6 +154,11 @@ trait ControllerTrait | |||
return $this->get(SectionResolver::class)->getCurrent(); | |||
} | |||
public function isOutOfSection() | |||
{ | |||
return is_null($this->getSectionCurrent()); | |||
} | |||
public function getSectionCurrentSlug(): string | |||
{ | |||
return $this->getSectionCurrent()->getSlug(); |
@@ -2,6 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Controller\Product; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||
@@ -9,6 +10,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; | |||
use Lc\CaracoleBundle\Controller\AbstractAdminController; | |||
use Lc\CaracoleBundle\Definition\ActionDefinition; | |||
use Lc\SovBundle\Field\CKEditorField; | |||
use Lc\SovBundle\Field\StatusField; | |||
use Lc\SovBundle\Field\ToggleField; | |||
@@ -34,4 +36,14 @@ abstract class ProductCategoryAdminController extends AbstractAdminController | |||
->getFields($pageName); | |||
} | |||
public function configureActions(Actions $actions): Actions | |||
{ | |||
$actions = parent::configureActions($actions); | |||
if(!$this->getSectionCurrent()) { | |||
$actions->disable(ActionDefinition::NEW); | |||
} | |||
return $actions; | |||
} | |||
} |
@@ -18,7 +18,6 @@ trait FieldDefinitionTrait | |||
return array_merge(parent::configureFieldsBase(), [ | |||
'section' => AssociationField::new('section') | |||
->setRequired(true) | |||
->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | |||
->setFormTypeOption('choices', $sectionArray) | |||
]); |
@@ -17,13 +17,13 @@ class TicketFieldDefinition extends SovTicketFieldDefinition | |||
public function __construct( | |||
TranslatorAdmin $translatorAdmin, | |||
TicketSolver $ticketSolver, | |||
SectionStore $sectionStore | |||
) { | |||
parent::__construct($translatorAdmin); | |||
parent::__construct($translatorAdmin, $ticketSolver); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureFields(): array | |||
{ | |||
return array_merge(parent::configureFields(), [ |
@@ -1,30 +0,0 @@ | |||
<?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() | |||
{ | |||
} | |||
} |
@@ -12,6 +12,8 @@ class MerchantFactory extends AbstractFactory | |||
{ | |||
$merchant = new Merchant(); | |||
$merchant->setStatus(1); | |||
return $merchant; | |||
} | |||
@@ -16,6 +16,7 @@ class NewsletterFactory extends SovNewsletterFactory | |||
$newsletter = parent::create(); | |||
$newsletter->setSection($this->section); | |||
$newsletter->setStatus(1); | |||
return $newsletter; | |||
} |
@@ -16,6 +16,7 @@ class PointSaleFactory extends AbstractFactory | |||
$pointSale = new PointSale(); | |||
$pointSale->addMerchant($merchant); | |||
$pointSale->setStatus(1); | |||
return $pointSale; | |||
} |
@@ -12,14 +12,14 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class ProductCategoryFactory extends AbstractFactory | |||
{ | |||
public function create(SectionInterface $section): ProductCategoryInterface | |||
{ | |||
$productCategory = new ProductCategory(); | |||
$productCategory->setSection($section); | |||
$productCategory->setSaleStatus(true); | |||
$productCategory->setStatus(1); | |||
return $productCategory; | |||
} | |||
} |
@@ -15,6 +15,9 @@ class ProductFamilyFactory extends AbstractFactory | |||
{ | |||
$productFamily = new ProductFamily(); | |||
$productFamily->setSaleStatus(true); | |||
$productFamily->setStatus(1); | |||
$productFamilySectionPropertyFactory = new ProductFamilySectionPropertyFactory(); | |||
foreach($merchant->getSections() as $section) { |
@@ -17,6 +17,7 @@ class ReductionCartFactory extends AbstractFactory | |||
$reductionCart = new ReductionCart(); | |||
$reductionCart->setSection($section); | |||
$reductionCart->setStatus(1); | |||
return $reductionCart; | |||
} |
@@ -17,6 +17,7 @@ class ReductionCatalogFactory extends AbstractFactory | |||
$reductionCatalog = new ReductionCatalog(); | |||
$reductionCatalog->setSection($section); | |||
$reductionCatalog->setStatus(1); | |||
return $reductionCatalog; | |||
} |
@@ -18,7 +18,10 @@ class PageFactory extends SovPageFactory | |||
$page = parent::create(); | |||
$page->setMerchant($this->merchant); | |||
$page->setSection($this->section); | |||
if(!is_null($this->section)) { | |||
$page->setSection($this->section); | |||
} | |||
return $page; | |||
} |
@@ -9,7 +9,7 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
interface ProductCategoryInterface | |||
{ | |||
public function getSection(): SectionInterface; | |||
public function getSection(): ?SectionInterface; | |||
public function setSection(SectionInterface $section): ProductCategoryModel; | |||
@@ -38,7 +38,7 @@ abstract class PageModel extends SovPageModel implements FilterMerchantInterface | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
public function getSection(): ?SectionInterface | |||
{ | |||
return $this->section; | |||
} |
@@ -25,7 +25,7 @@ class OpeningStore extends AbstractStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterBySection($this->section); | |||
$this->addFilterBySectionOptionnal($query); | |||
return $query; | |||
} | |||
@@ -33,5 +33,4 @@ class OpeningStore extends AbstractStore | |||
{ | |||
return $query; | |||
} | |||
} |
@@ -73,8 +73,7 @@ class SectionResolver | |||
} | |||
} // front | |||
else { | |||
dump('front'); | |||
dump($requestAttributesArray); | |||
if($this->section === null) { | |||
$merchantCurrent = $this->merchantResolver->getCurrent(); | |||
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); |
@@ -7,7 +7,7 @@ use Lc\SovBundle\Solver\Ticket\TicketSolver as SovTicketSolver; | |||
class TicketSolver extends SovTicketSolver | |||
{ | |||
public static function getTypeChoices(): array | |||
public function getTypeChoices(): array | |||
{ | |||
$choices = parent::getTypeChoices(); | |||
$choicesProduct = [ |