@@ -646,7 +646,6 @@ class OrderShopBuilder | |||
$orderShop->setDeclineComplementaryOrderShop(false); | |||
} | |||
public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2) | |||
{ | |||
$productsSalesStatistic = new ProductsSalesStatistic( |
@@ -47,6 +47,8 @@ class AddressContainer | |||
public function getStore(): AddressStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -34,6 +34,8 @@ class TaxRateContainer | |||
public function getStore(): TaxRateStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
} |
@@ -51,6 +51,8 @@ class CreditHistoryContainer | |||
public function getStore(): CreditHistoryStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -34,6 +34,8 @@ class DocumentContainer | |||
public function getStore(): DocumentStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
} |
@@ -59,6 +59,8 @@ class OrderShopContainer | |||
public function getStore(): OrderShopStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -52,6 +52,8 @@ class PointSaleContainer | |||
public function getStore(): PointSaleStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
} |
@@ -2,6 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Container\Product; | |||
use Lc\CaracoleBundle\Definition\Field\Product\ProductCategoryFieldDefinition; | |||
use Lc\CaracoleBundle\Factory\Product\ProductCategoryFactory; | |||
use Lc\CaracoleBundle\Repository\Product\ProductCategoryRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; | |||
@@ -13,17 +14,20 @@ class ProductCategoryContainer | |||
protected ProductCategorySolver $solver; | |||
protected ProductCategoryRepositoryQuery $repositoryQuery; | |||
protected ProductCategoryStore $store; | |||
protected ProductCategoryFieldDefinition $fieldDefinition; | |||
public function __construct( | |||
ProductCategoryFactory $factory, | |||
ProductCategorySolver $solver, | |||
ProductCategoryRepositoryQuery $repositoryQuery, | |||
ProductCategoryStore $store | |||
ProductCategoryStore $store, | |||
ProductCategoryFieldDefinition $fieldDefinition | |||
) { | |||
$this->factory = $factory; | |||
$this->solver = $solver; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
$this->fieldDefinition = $fieldDefinition; | |||
} | |||
public function getFactory(): ProductCategoryFactory | |||
@@ -43,7 +47,14 @@ class ProductCategoryContainer | |||
public function getStore(): ProductCategoryStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
public function getFieldDefinition(): ProductCategoryFieldDefinition | |||
{ | |||
return $this->fieldDefinition; | |||
} | |||
} |
@@ -43,6 +43,8 @@ class ProductContainer | |||
public function getStore(): ProductStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -55,6 +55,8 @@ class ProductFamilyContainer | |||
public function getStore(): ProductFamilyStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -54,6 +54,8 @@ class ProductFamilySectionPropertyContainer | |||
public function getStore(): ProductFamilySectionPropertyStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -2,6 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Container\Reduction; | |||
use Lc\CaracoleBundle\Definition\Field\Reduction\ReductionCartFieldDefinition; | |||
use Lc\CaracoleBundle\Factory\Reduction\ReductionCartFactory; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore; | |||
@@ -11,15 +12,18 @@ class ReductionCartContainer | |||
protected ReductionCartFactory $factory; | |||
protected ReductionCartRepositoryQuery $repositoryQuery; | |||
protected ReductionCartStore $store; | |||
protected ReductionCartFieldDefinition $fieldDefinition; | |||
public function __construct( | |||
ReductionCartFactory $factory, | |||
ReductionCartRepositoryQuery $repositoryQuery, | |||
ReductionCartStore $store | |||
ReductionCartStore $store, | |||
ReductionCartFieldDefinition $fieldDefinition | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
$this->fieldDefinition = $fieldDefinition; | |||
} | |||
public function getFactory(): ReductionCartFactory | |||
@@ -34,7 +38,13 @@ class ReductionCartContainer | |||
public function getStore(): ReductionCartStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
public function getFieldDefinition(): ReductionCartFieldDefinition | |||
{ | |||
return $this->fieldDefinition; | |||
} | |||
} |
@@ -2,6 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Container\Reduction; | |||
use Lc\CaracoleBundle\Definition\Field\Reduction\ReductionCatalogFieldDefinition; | |||
use Lc\CaracoleBundle\Factory\Reduction\ReductionCatalogFactory; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore; | |||
@@ -11,15 +12,18 @@ class ReductionCatalogContainer | |||
protected ReductionCatalogFactory $factory; | |||
protected ReductionCatalogRepositoryQuery $repositoryQuery; | |||
protected ReductionCatalogStore $store; | |||
protected ReductionCatalogFieldDefinition $fieldDefinition; | |||
public function __construct( | |||
ReductionCatalogFactory $factory, | |||
ReductionCatalogRepositoryQuery $repositoryQuery, | |||
ReductionCatalogStore $store | |||
ReductionCatalogStore $store, | |||
ReductionCatalogFieldDefinition $fieldDefinition | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
$this->fieldDefinition = $fieldDefinition; | |||
} | |||
public function getFactory(): ReductionCatalogFactory | |||
@@ -34,7 +38,14 @@ class ReductionCatalogContainer | |||
public function getStore(): ReductionCatalogStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
public function getFieldDefinition(): ReductionCatalogFieldDefinition | |||
{ | |||
return $this->fieldDefinition; | |||
} | |||
} |
@@ -43,6 +43,8 @@ class OpeningContainer | |||
public function getStore(): OpeningStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -52,6 +52,8 @@ class SectionContainer | |||
public function getStore(): SectionStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
} |
@@ -47,6 +47,8 @@ class MerchantSettingContainer | |||
public function getStore(): MerchantSettingStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -47,6 +47,8 @@ class SectionSettingContainer | |||
public function getStore(): SectionSettingStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -51,6 +51,8 @@ class UserMerchantContainer | |||
public function getStore(): UserMerchantStore | |||
{ | |||
$this->store->resetContext(); | |||
return $this->store; | |||
} | |||
@@ -6,9 +6,9 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
trait SectionContextTrait | |||
{ | |||
protected SectionInterface $section; | |||
protected ?SectionInterface $section; | |||
public function setSection(SectionInterface $section) | |||
public function setSection(?SectionInterface $section) | |||
{ | |||
$this->section = $section; | |||
@@ -3,7 +3,6 @@ | |||
namespace Lc\CaracoleBundle\Controller; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Doctrine\ORM\QueryBuilder; | |||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; | |||
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Action; | |||
@@ -15,36 +14,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | |||
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | |||
use Lc\CaracoleBundle\Container\Address\AddressContainer; | |||
use Lc\CaracoleBundle\Container\Config\TaxRateContainer; | |||
use Lc\CaracoleBundle\Container\Config\UnitContainer; | |||
use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer; | |||
use Lc\CaracoleBundle\Container\File\DocumentContainer; | |||
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderPaymentContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderProductContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderProductReductionCatalogContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderProductRefundContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderReductionCartContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderReductionCreditContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderRefundContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderStatusContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderStatusHistoryContainer; | |||
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | |||
use Lc\CaracoleBundle\Container\Section\OpeningContainer; | |||
use Lc\CaracoleBundle\Container\Section\SectionContainer; | |||
use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer; | |||
use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer; | |||
use Lc\CaracoleBundle\Container\User\UserMerchantContainer; | |||
use Lc\CaracoleBundle\Container\User\UserPointSaleContainer; | |||
use Lc\CaracoleBundle\Container\User\VisitorContainer; | |||
use Lc\CaracoleBundle\Definition\ActionDefinition; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface; | |||
@@ -63,66 +32,27 @@ use Symfony\Component\HttpFoundation\Response; | |||
trait AdminControllerTrait | |||
{ | |||
use ControllerTrait; | |||
//TODO doit implementer ControllerTrait | |||
/*public static function getSubscribedServices() | |||
{ | |||
return array_merge( | |||
parent::getSubscribedServices(), | |||
self::getSubscribedServicesList() | |||
); | |||
} | |||
public static function getSubscribedServicesList() | |||
{ | |||
return [ | |||
MerchantResolver::class => MerchantResolver::class, | |||
SectionResolver::class => SectionResolver::class, | |||
AddressContainer::class => AddressContainer::class, | |||
TaxRateContainer::class => TaxRateContainer::class, | |||
UnitContainer::class => UnitContainer::class, | |||
CreditHistoryContainer::class => CreditHistoryContainer::class, | |||
DocumentContainer::class => DocumentContainer::class, | |||
MerchantContainer::class => MerchantContainer::class, | |||
OrderPaymentContainer::class => OrderPaymentContainer::class, | |||
OrderProductContainer::class => OrderProductContainer::class, | |||
OrderProductReductionCatalogContainer::class => OrderProductReductionCatalogContainer::class, | |||
OrderProductRefundContainer::class => OrderProductRefundContainer::class, | |||
OrderReductionCartContainer::class => OrderReductionCartContainer::class, | |||
OrderReductionCreditContainer::class => OrderReductionCreditContainer::class, | |||
OrderRefundContainer::class => OrderRefundContainer::class, | |||
OrderShopContainer::class => OrderShopContainer::class, | |||
OrderStatusContainer::class => OrderStatusContainer::class, | |||
OrderStatusHistoryContainer::class => OrderStatusHistoryContainer::class, | |||
PointSaleContainer::class => PointSaleContainer::class, | |||
ProductCategoryContainer::class => ProductCategoryContainer::class, | |||
ProductContainer::class => ProductContainer::class, | |||
ProductFamilyContainer::class => ProductFamilyContainer::class, | |||
ReductionCartContainer::class => ReductionCartContainer::class, | |||
ReductionCatalogContainer::class => ReductionCatalogContainer::class, | |||
ReductionCreditContainer::class => ReductionCreditContainer::class, | |||
OpeningContainer::class => OpeningContainer::class, | |||
SectionContainer::class => SectionContainer::class, | |||
MerchantSettingContainer::class => MerchantSettingContainer::class, | |||
SectionSettingContainer::class => SectionSettingContainer::class, | |||
UserMerchantContainer::class => UserMerchantContainer::class, | |||
UserPointSaleContainer::class => UserPointSaleContainer::class, | |||
VisitorContainer::class => VisitorContainer::class | |||
]; | |||
}*/ | |||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | |||
{ | |||
$responseParameters = parent::configureResponseParameters($responseParameters); | |||
// affichage du filtre sur section | |||
$this->configureResponseParametersFilterSection($responseParameters); | |||
return $responseParameters; | |||
} | |||
public function configureResponseParametersFilterSection(KeyValueStore $responseParameters) | |||
{ | |||
if ($this->isInstanceOf(FilterSectionInterface::class)) { | |||
$responseParameters->set('display_switch_section', true); | |||
} | |||
} | |||
return $responseParameters; | |||
public function configureResponseParametersDisableShowAllSections(KeyValueStore $responseParameters) | |||
{ | |||
$responseParameters->set('replace_content_with_message', "Vous devez sélectionner une section pour afficher ces données."); | |||
} | |||
public function createIndexRepositoryQuery( | |||
@@ -138,12 +68,15 @@ trait AdminControllerTrait | |||
$filters | |||
); | |||
if ($this->isInstanceOf(FilterMerchantInterface::class) || $this->isInstanceOf(FilterMultipleMerchantsInterface::class)) { | |||
$sectionCurrent = $this->get(SectionResolver::class)->getCurrent(); | |||
if ($this->isInstanceOf(FilterMerchantInterface::class) | |||
|| $this->isInstanceOf(FilterMultipleMerchantsInterface::class)) { | |||
$repositoryQuery->filterByMerchant($this->get(MerchantResolver::class)->getCurrent()); | |||
} | |||
if ($this->isInstanceOf(FilterSectionInterface::class)) { | |||
$repositoryQuery->filterBySection($this->get(SectionResolver::class)->getCurrent()); | |||
if ($sectionCurrent && $this->isInstanceOf(FilterSectionInterface::class)) { | |||
$repositoryQuery->filterBySection($sectionCurrent); | |||
} | |||
return $repositoryQuery; |
@@ -40,6 +40,7 @@ use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | |||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | |||
use Lc\CaracoleBundle\Notification\MailMailjetNotification; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
@@ -54,6 +55,7 @@ trait ControllerTrait | |||
return array_merge( | |||
parent::getSubscribedServices(), | |||
[ | |||
MailMailjetNotification::class => MailMailjetNotification::class, | |||
PriceSolver::class => PriceSolver::class, | |||
MerchantResolver::class => MerchantResolver::class, | |||
SectionResolver::class => SectionResolver::class, | |||
@@ -94,6 +96,11 @@ trait ControllerTrait | |||
); | |||
} | |||
public function getMailMailjetNotification() | |||
{ | |||
return $this->get(MailMailjetNotification::class); | |||
} | |||
public function getMerchantSettingCurrent(string $settingName) | |||
{ | |||
return $this->getSettingValue($this->getMerchantCurrent(), $settingName); | |||
@@ -142,7 +149,7 @@ trait ControllerTrait | |||
return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent()); | |||
} | |||
public function getSectionCurrent(): SectionInterface | |||
public function getSectionCurrent(): ?SectionInterface | |||
{ | |||
return $this->get(SectionResolver::class)->getCurrent(); | |||
} |
@@ -3,10 +3,8 @@ | |||
namespace Lc\CaracoleBundle\Controller\Newsletter; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\SovBundle\Container\Newsletter\NewsletterContainer; | |||
use Lc\SovBundle\Controller\Newsletter\NewsletterAdminController as SovNewsletterAdminController; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
abstract class NewsletterAdminController extends SovNewsletterAdminController | |||
{ | |||
@@ -16,7 +14,15 @@ abstract class NewsletterAdminController extends SovNewsletterAdminController | |||
{ | |||
return $this->get(NewsletterContainer::class) | |||
->getFactory() | |||
->setSection($this->get(SectionResolver::class)->getCurrent()) | |||
->setSection($this->getSectionCurrent()) | |||
->create(); | |||
} | |||
public function configureFields(string $pageName): iterable | |||
{ | |||
return $this->getNewsletterContainer()->getFieldDefinition() | |||
->setMerchant($this->getMerchantCurrent()) | |||
->setSection($this->getSectionCurrent()) | |||
->getFields($pageName); | |||
} | |||
} |
@@ -28,23 +28,10 @@ abstract class ProductCategoryAdminController extends AbstractAdminController | |||
public function configureFields(string $pageName): iterable | |||
{ | |||
return array_merge( | |||
[ | |||
FormField::addPanel('general'), | |||
IntegerField::new('id')->onlyOnIndex()->setSortable(true), | |||
TextField::new('title')->setSortable(true), | |||
NumberField::new('position')->hideOnForm()->setSortable(true), | |||
AssociationField::new('parent')->hideOnIndex(), | |||
DateTimeField::new('createdAt')->setFormat('short')->setSortable(true), | |||
CKEditorField::new('description')->hideOnIndex(), | |||
StatusField::new('status')->setSortable(true), | |||
ToggleField::new('saleStatus')->setSortable(true), | |||
ToggleField::new('isEligibleTicketRestaurant')->setSortable(true), | |||
], | |||
$this->getSeoPanel(), | |||
$this->getConfPanel() | |||
); | |||
return $this->getProductCategoryContainer()->getFieldDefinition() | |||
->setMerchant($this->getMerchantCurrent()) | |||
->setSection($this->getSectionCurrent()) | |||
->getFields($pageName); | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Controller\Section; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField; | |||
@@ -17,11 +18,27 @@ abstract class OpeningAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->getOpeningContainer() | |||
->getFactory() | |||
->create($this->getSectionCurrent()); | |||
} | |||
public function getRepositoryQuery() :RepositoryQueryInterface | |||
{ | |||
return $this->get(OpeningContainer::class)->getRepositoryQuery(); | |||
} | |||
public function configureCrud(Crud $crud): Crud | |||
{ | |||
$crud = parent::configureCrud($crud); | |||
$crud->setDefaultSort(['day' => 'ASC']); | |||
return $crud; | |||
} | |||
public function configureFields(string $pageName): iterable | |||
{ | |||
return [ | |||
@@ -48,19 +65,13 @@ abstract class OpeningAdminController extends AbstractAdminController | |||
]; | |||
} | |||
public function configureCrud(Crud $crud): Crud | |||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | |||
{ | |||
$crud = parent::configureCrud($crud); | |||
$responseParameters = parent::configureResponseParameters($responseParameters); | |||
$crud->setDefaultSort(['day' => 'ASC']); | |||
$this->configureResponseParametersFilterSection($responseParameters); | |||
$this->configureResponseParametersDisableShowAllSections($responseParameters); | |||
return $crud; | |||
} | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->getOpeningContainer() | |||
->getFactory() | |||
->create($this->getSectionCurrent()); | |||
return $responseParameters; | |||
} | |||
} |
@@ -17,7 +17,6 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
abstract class SectionAdminController extends AbstractAdminController | |||
{ | |||
public function getRepositoryQuery() :RepositoryQueryInterface | |||
{ | |||
return $this->get(SectionContainer::class)->getRepositoryQuery(); |
@@ -27,13 +27,19 @@ class SwitchSectionAdminController extends AbstractController | |||
$form->handleRequest($request); | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
// valeur par défaut de $section : Tout afficher | |||
$section = null; | |||
$idSection = $form->get('id_section')->getData(); | |||
$section = $sectionContainer->getStore()->getOneById($idSection); | |||
$userMerchant = $merchantResolver->getUserMerchant(); | |||
if ($section && $userMerchant) { | |||
if($userMerchant) { | |||
if($idSection) { | |||
$section = $sectionContainer->getStore()->getOneById($idSection); | |||
} | |||
$userMerchant->setCurrentAdminSection($section); | |||
$entityManager->update($section); | |||
$entityManager->update($userMerchant); | |||
$entityManager->flush(); | |||
} | |||
} |
@@ -2,19 +2,11 @@ | |||
namespace Lc\CaracoleBundle\Controller\Setting; | |||
use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer; | |||
use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer; | |||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\SovBundle\Container\Setting\SiteSettingContainer; | |||
use Lc\SovBundle\Container\Site\SiteContainer; | |||
use Lc\SovBundle\Controller\Setting\SettingAdminController as SovSettingController; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\CaracoleBundle\Form\Setting\MerchantSettingsFormType; | |||
use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType; | |||
use Lc\SovBundle\Form\Setting\SiteSettingsFormType; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
use Symfony\Component\HttpFoundation\Request; | |||
use Symfony\Component\Routing\Annotation\Route; | |||
@@ -25,18 +17,16 @@ class SettingAdminController extends SovSettingController | |||
/** | |||
* @Route("/admin/setting/merchant", name="carac_admin_setting_merchant") | |||
*/ | |||
public function manageMerchant( | |||
Request $request | |||
) { | |||
public function manageMerchant(Request $request) | |||
{ | |||
return $this->manage($request, 'merchant'); | |||
} | |||
/** | |||
* @Route("/admin/setting/section", name="carac_admin_setting_section") | |||
*/ | |||
public function manageSection( | |||
Request $request | |||
) { | |||
public function manageSection(Request $request) | |||
{ | |||
return $this->manage($request, 'section'); | |||
} | |||
@@ -58,6 +48,8 @@ class SettingAdminController extends SovSettingController | |||
} | |||
$entity = $resolver->getCurrent(); | |||
$displaySwitchSection = ($type == 'section') ? true : false; | |||
$view = '@LcCaracole/admin/setting/edit_' . $type . '.html.twig'; | |||
if ($entity) { | |||
$form = $this->createForm($formClass, $entity); | |||
@@ -68,19 +60,28 @@ class SettingAdminController extends SovSettingController | |||
$entityManager->update($entity); | |||
$entityManager->flush(); | |||
$this->addFlashTranslator('success','updated'); | |||
$this->addFlashTranslator('success', 'updated'); | |||
} | |||
return $this->render( | |||
'@LcCaracole/admin/setting/edit_' . $type . '.html.twig', | |||
$view, | |||
[ | |||
'display_switch_section' => ($type == 'section') ? true : false, | |||
'display_switch_section' => $displaySwitchSection, | |||
'resolver' => $resolver, | |||
'setting_definition' => $settingDefinition, | |||
'form' => $form->createView() | |||
] | |||
); | |||
} | |||
else { | |||
return $this->render( | |||
$view, | |||
[ | |||
'display_switch_section' => $displaySwitchSection, | |||
'replace_content_with_message' => "Vous devez sélectionner une section pour afficher ces données." | |||
] | |||
); | |||
} | |||
} | |||
/** | |||
@@ -98,7 +99,7 @@ class SettingAdminController extends SovSettingController | |||
$entityManager->update($site); | |||
$entityManager->flush(); | |||
$this->addFlashTranslator('success','updated'); | |||
$this->addFlashTranslator('success', 'updated'); | |||
} | |||
return $this->render( |
@@ -2,12 +2,12 @@ | |||
namespace Lc\CaracoleBundle\Controller\Site; | |||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController; | |||
abstract class NewsAdminController extends SovNewsAdminController | |||
{ | |||
use ControllerTrait; | |||
use AdminControllerTrait; | |||
public function createEntity(string $entityFqcn) | |||
{ |
@@ -2,18 +2,18 @@ | |||
namespace Lc\CaracoleBundle\Controller\Site; | |||
use Lc\CaracoleBundle\Controller\ControllerTrait; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController; | |||
abstract class PageAdminController extends SovPageAdminController | |||
{ | |||
use ControllerTrait; | |||
use AdminControllerTrait; | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->getPageContainer() | |||
->getFactory() | |||
->setMerchant($this->getMerchantCurrent()) | |||
->setSection($this->getSectionCurrent()) | |||
->create(); | |||
} |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field; | |||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition as SovAbstractFieldDefinition; | |||
abstract class AbstractFieldDefinition extends SovAbstractFieldDefinition | |||
{ | |||
use FieldDefinitionTrait; | |||
} |
@@ -0,0 +1,46 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field; | |||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||
use Lc\CaracoleBundle\Context\SectionContextTrait; | |||
use Lc\CaracoleBundle\Field\AssociationField; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
trait FieldDefinitionTrait | |||
{ | |||
use MerchantContextTrait; | |||
use SectionContextTrait; | |||
public function configureFieldsBase(): array | |||
{ | |||
$sectionArray = $this->sectionStore->setMerchant($this->merchant)->get(); | |||
return array_merge(parent::configureFieldsBase(), [ | |||
'section' => AssociationField::new('section') | |||
->setTemplatePath('@LcCaracole/admin/section/field/section.html.twig') | |||
->setFormTypeOption('choices', $sectionArray) | |||
]); | |||
} | |||
public function addSectionToFieldArrayIfOutOfSection(?SectionInterface $sectionCurrent, array $fieldArray) | |||
{ | |||
$asObject = true; | |||
if(is_string($fieldArray[array_key_first($fieldArray)])) { | |||
$asObject = false; | |||
} | |||
$fieldSectionArray = []; | |||
if($sectionCurrent == null) { | |||
if($asObject) { | |||
$allFieldArray = $this->getAllFields(); | |||
$fieldSectionArray = [$allFieldArray['section']]; | |||
} | |||
else { | |||
$fieldSectionArray = ['section']; | |||
} | |||
} | |||
return array_merge($fieldSectionArray, $fieldArray); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field\Newsletter; | |||
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Definition\Field\Newsletter\NewsletterFieldDefinition as SovNewsletterFieldDefinition; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
class NewsletterFieldDefinition extends SovNewsletterFieldDefinition | |||
{ | |||
use FieldDefinitionTrait; | |||
protected SectionStore $sectionStore; | |||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||
{ | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureIndex(): array | |||
{ | |||
return $this->addSectionToFieldArrayIfOutOfSection($this->section, [ | |||
'id', | |||
'title', | |||
'isMain', | |||
'status' | |||
]); | |||
} | |||
public function configurePanelMain(): array | |||
{ | |||
return array_merge(['section'], parent::configurePanelMain()); | |||
} | |||
} |
@@ -9,14 +9,24 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition; | |||
use Lc\CaracoleBundle\Field\AssociationField; | |||
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
use Symfony\Component\Form\Extension\Core\Type\TextType; | |||
class OrderShopFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
use MerchantContextTrait; | |||
protected SectionStore $sectionStore; | |||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||
{ | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureFieldsIndex(): array | |||
{ | |||
return ['id']; |
@@ -0,0 +1,79 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field\Product; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition; | |||
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Field\CKEditorField; | |||
use Lc\SovBundle\Field\ToggleField; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
class ProductCategoryFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
protected SectionStore $sectionStore; | |||
protected ProductCategoryStore $productCategoryStore; | |||
public function __construct( | |||
TranslatorAdmin $translatorAdmin, | |||
SectionStore $sectionStore, | |||
ProductCategoryStore $productCategoryStore | |||
) { | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
$this->productCategoryStore = $productCategoryStore; | |||
} | |||
public function configureIndex(): array | |||
{ | |||
$fieldArray = ($this->section == null) ? ['section'] : []; | |||
return array_merge($fieldArray, [ | |||
'id', | |||
'title', | |||
'status' | |||
]); | |||
} | |||
public function configurePanels(): array | |||
{ | |||
return [ | |||
'main', | |||
'seo', | |||
'conf' | |||
]; | |||
} | |||
public function configurePanelMain() | |||
{ | |||
return [ | |||
'section', | |||
'title', | |||
'parent', | |||
'description', | |||
'isEligibleTicketRestaurant', | |||
'saleStatus', | |||
'status', | |||
]; | |||
} | |||
public function configureFields(): array | |||
{ | |||
$productCategoryArray = $this->productCategoryStore | |||
->setSection($this->section) | |||
->getParents(); | |||
return [ | |||
'title' => TextField::new('title')->setSortable(true), | |||
'position' => NumberField::new('position')->setSortable(true), | |||
'parent' => AssociationField::new('parent') | |||
->setFormTypeOption('choices', $productCategoryArray), | |||
'description' => CKEditorField::new('description'), | |||
'saleStatus' => ToggleField::new('saleStatus')->setSortable(true), | |||
'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true), | |||
]; | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field\Reduction; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
class ReductionCartFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
protected SectionStore $sectionStore; | |||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||
{ | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureFields(): array | |||
{ | |||
return [ | |||
'title' => TextField::new('title')->setSortable(true) | |||
// @TODO : à faire | |||
]; | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field\Reduction; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Definition\Field\AbstractFieldDefinition; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
class ReductionCatalogFieldDefinition extends AbstractFieldDefinition | |||
{ | |||
protected SectionStore $sectionStore; | |||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||
{ | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureFields(): array | |||
{ | |||
return [ | |||
'title' => TextField::new('title')->setSortable(true) | |||
// @TODO : à faire | |||
]; | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field\Site; | |||
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | |||
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; | |||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||
{ | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureIndex(): array | |||
{ | |||
return $this->addSectionToFieldArrayIfOutOfSection($this->section, parent::configureIndex()); | |||
} | |||
public function configurePanelMain(): array | |||
{ | |||
return array_merge(['section'], parent::configurePanelMain()); | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Definition\Field\Site; | |||
use Lc\CaracoleBundle\Definition\Field\FieldDefinitionTrait; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\SovBundle\Definition\Field\Site\PageFieldDefinition as SovPageFieldDefinition; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
class PageFieldDefinition extends SovPageFieldDefinition | |||
{ | |||
use FieldDefinitionTrait; | |||
protected SectionStore $sectionStore; | |||
public function __construct(TranslatorAdmin $translatorAdmin, SectionStore $sectionStore) | |||
{ | |||
parent::__construct($translatorAdmin); | |||
$this->sectionStore = $sectionStore; | |||
} | |||
public function configureIndex(): array | |||
{ | |||
return [ | |||
'id', | |||
'title', | |||
'status' | |||
]; | |||
} | |||
} |
@@ -10,12 +10,14 @@ use Lc\SovBundle\Model\Site\PageInterface; | |||
class PageFactory extends SovPageFactory | |||
{ | |||
use MerchantContextTrait; | |||
use SectionContextTrait; | |||
public function create(): PageInterface | |||
{ | |||
$page = parent::create(); | |||
$page->setMerchant($this->merchant); | |||
$page->setSection($this->section); | |||
return $page; |
@@ -119,6 +119,9 @@ final class AssociationField implements FieldInterface | |||
return $this; | |||
} | |||
/** | |||
* @deprecated Utiliser setFormTypeOption('choices', $choices) avec $choices issu d'un Store. | |||
*/ | |||
public function initQueryBuilder(): self | |||
{ | |||
$param = $this->queryBuilderParameters; |
@@ -6,6 +6,7 @@ use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Repository\Section\SectionRepository; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\CaracoleBundle\Solver\Section\SectionSolver; | |||
use Lc\SovBundle\Doctrine\EntityManager; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
@@ -19,18 +20,21 @@ use Symfony\Component\OptionsResolver\OptionsResolver; | |||
class SwitchSectionFormType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $translatorAdmin; | |||
protected $sectionResolver; | |||
protected EntityManager $em; | |||
protected TranslatorAdmin $translatorAdmin; | |||
protected SectionResolver $sectionResolver; | |||
protected SectionSolver $sectionSolver; | |||
public function __construct( | |||
EntityManager $em, | |||
TranslatorAdmin $translatorAdmin, | |||
SectionResolver $sectionResolver | |||
SectionResolver $sectionResolver, | |||
SectionSolver $sectionSolver | |||
) { | |||
$this->em = $em; | |||
$this->translatorAdmin = $translatorAdmin; | |||
$this->sectionResolver = $sectionResolver; | |||
$this->sectionSolver = $sectionSolver; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
@@ -49,15 +53,14 @@ class SwitchSectionFormType extends AbstractType | |||
$styleButton = ''; | |||
$classButton = 'btn-section'; | |||
if ($section == $currentSection) { | |||
$classButton .= ' btn-section-current section-'.$currentSection->getDevAlias(); | |||
//$styleButton = 'color: white; background-color: ' . $currentSection->getColor() . ';'; | |||
$classButton .= ' btn-section-current '.$this->sectionSolver->getHtmlClass($currentSection); | |||
} | |||
$builder->add( | |||
'submit', | |||
SubmitType::class, | |||
[ | |||
'label' => $section ? $section->getTitle() : '', | |||
'label' => $section ? $section->getTitle() : 'Tout afficher', | |||
'attr' => [ | |||
'class' => $classButton, | |||
'style' => $styleButton, |
@@ -3,22 +3,41 @@ | |||
namespace Lc\CaracoleBundle\Model\Site; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Model\Site\PageModel as SovPageModel; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class PageModel extends SovPageModel implements FilterSectionInterface | |||
abstract class PageModel extends SovPageModel implements FilterMerchantInterface, FilterSectionInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | |||
* @ORM\JoinColumn(nullable=false) | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $section; | |||
public function getMerchant(): ?MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; | |||
@@ -30,5 +49,4 @@ abstract class PageModel extends SovPageModel implements FilterSectionInterface | |||
return $this; | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Repository; | |||
Use Lc\SovBundle\Repository\AbstractStore as SovAbstractStore; | |||
abstract class AbstractStore extends SovAbstractStore | |||
{ | |||
use StoreTrait; | |||
} |
@@ -2,9 +2,9 @@ | |||
namespace Lc\CaracoleBundle\Repository\Address; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class AddressStore extends AbstractStore |
@@ -2,10 +2,8 @@ | |||
namespace Lc\CaracoleBundle\Repository\Config; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class TaxRateStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Config; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class UnitStore extends AbstractStore |
@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Credit; | |||
use App\Entity\User\UserMerchant; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use DateTime; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
@@ -3,9 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Distribution; | |||
use App\Entity\Distribution\Distribution; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore;; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class DistributionStore extends AbstractStore |
@@ -6,7 +6,7 @@ use App\Entity\Address\Address; | |||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class DocumentStore extends AbstractStore |
@@ -2,8 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Merchant; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class MerchantStore extends AbstractStore |
@@ -8,9 +8,9 @@ use Lc\SovBundle\Repository\StoreInterface; | |||
trait MerchantStoreTrait | |||
{ | |||
protected MerchantInterface $merchant; | |||
protected ?MerchantInterface $merchant = null; | |||
public function setMerchant(MerchantInterface $merchant):self | |||
public function setMerchant(?MerchantInterface $merchant):self | |||
{ | |||
$this->merchant = $merchant; | |||
@@ -4,11 +4,13 @@ namespace Lc\CaracoleBundle\Repository\Newsletter; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\Newsletter\NewsletterStore as SovNewsletterStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class NewsletterStore extends SovNewsletterStore | |||
{ | |||
use StoreTrait; | |||
use SectionStoreTrait; | |||
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderPaymentStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderProductReductionCatalogStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderProductRefundStore extends AbstractStore |
@@ -6,7 +6,7 @@ use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderProductStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderReductionCartStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderReductionCreditStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderRefundStore extends AbstractStore |
@@ -25,7 +25,7 @@ use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderStatusHistoryStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Order; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OrderStatusStore extends AbstractStore |
@@ -3,7 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\PointSale; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class PointSaleStore extends AbstractStore |
@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Product; | |||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ProductCategoryStore extends AbstractStore |
@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Product; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ProductFamilySectionPropertyStore extends AbstractStore |
@@ -9,7 +9,7 @@ use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ProductFamilyStore extends AbstractStore |
@@ -3,7 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Product; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ProductStore extends AbstractStore | |||
@@ -24,8 +24,9 @@ class ProductStore extends AbstractStore | |||
public function filtersDefault($query):RepositoryQueryInterface | |||
{ | |||
$this->addFilterBySectionOptionnal($query); | |||
$query->filterIsOnlineAndOffline(); | |||
$query->filterBySection($this->section); | |||
return $query; | |||
} | |||
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Product; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class QualityLabelStore extends AbstractStore |
@@ -2,15 +2,11 @@ | |||
namespace Lc\CaracoleBundle\Repository\Reduction; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | |||
class ReductionCartStore extends AbstractStore | |||
{ |
@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Reduction; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ReductionCatalogStore extends AbstractStore |
@@ -2,14 +2,10 @@ | |||
namespace Lc\CaracoleBundle\Repository\Reduction; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ReductionCreditStore extends AbstractStore |
@@ -4,12 +4,13 @@ namespace Lc\CaracoleBundle\Repository\Reminder; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ReminderStore extends SovReminderStore | |||
{ | |||
use StoreTrait; | |||
use SectionStoreTrait; | |||
use MerchantStoreTrait; | |||
@@ -3,8 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Section; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Solver\Section\OpeningSolver; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class OpeningStore extends AbstractStore |
@@ -2,11 +2,10 @@ | |||
namespace Lc\CaracoleBundle\Repository\Section; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||
@@ -10,7 +10,7 @@ trait SectionStoreTrait | |||
{ | |||
protected ?SectionInterface $section = null; | |||
public function setSection(SectionInterface $section):self | |||
public function setSection(?SectionInterface $section):self | |||
{ | |||
$this->section = $section; | |||
@@ -3,7 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Setting; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class MerchantSettingStore extends AbstractStore |
@@ -3,7 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Setting; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class SectionSettingStore extends AbstractStore |
@@ -3,16 +3,18 @@ | |||
namespace Lc\CaracoleBundle\Repository\Site; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Lc\SovBundle\Repository\Site\NewsStore as SovNewsStore; | |||
class NewsStore extends SovNewsStore | |||
{ | |||
use StoreTrait; | |||
use SectionStoreTrait; | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterBySection($this->section); | |||
$this->addFilterBySectionOptionnal($query); | |||
return parent::filtersDefault($query); | |||
} | |||
@@ -2,11 +2,12 @@ | |||
namespace Lc\CaracoleBundle\Repository\Site; | |||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||
use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery; | |||
class PageRepositoryQuery extends SovPageRepositoryQuery | |||
{ | |||
use MerchantRepositoryQueryTrait; | |||
use SectionRepositoryQueryTrait; | |||
} |
@@ -2,14 +2,16 @@ | |||
namespace Lc\CaracoleBundle\Repository\Site; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Model\Site\PageInterface; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Lc\SovBundle\Repository\Site\PageStore as SovPageStore; | |||
class PageStore extends SovPageStore | |||
{ | |||
use StoreTrait; | |||
use MerchantStoreTrait; | |||
use SectionStoreTrait; | |||
public function __construct(PageRepositoryQuery $query) | |||
@@ -19,7 +21,9 @@ class PageStore extends SovPageStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterBySection($this->section); | |||
$this->addFilterByMerchantOptionnal($query); | |||
$this->addFilterBySectionOptionnal($query); | |||
return parent::filtersDefault($query); | |||
} | |||
@@ -0,0 +1,17 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Repository; | |||
trait StoreTrait | |||
{ | |||
public function resetContext(): void | |||
{ | |||
if(method_exists($this, 'setMerchant')) { | |||
$this->setMerchant(null); | |||
} | |||
if(method_exists($this, 'setSection')) { | |||
$this->setSection(null); | |||
} | |||
} | |||
} |
@@ -3,17 +3,18 @@ | |||
namespace Lc\CaracoleBundle\Repository\Ticket; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Lc\SovBundle\Repository\Ticket\TicketStore as SovTicketStore; | |||
class TicketStore extends SovTicketStore | |||
{ | |||
use StoreTrait; | |||
use SectionStoreTrait; | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterBySection($this->section); | |||
$this->addFilterBySectionOptionnal($query); | |||
return $query; | |||
} | |||
@@ -3,17 +3,18 @@ | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Lc\SovBundle\Repository\User\GroupUserStore as SovGroupUserStore; | |||
class GroupUserStore extends SovGroupUserStore | |||
{ | |||
use StoreTrait; | |||
use MerchantStoreTrait; | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterByMerchant($this->merchant); | |||
$this->addFilterByMerchantOptionnal($query); | |||
return parent::filtersDefault($query); | |||
} | |||
} |
@@ -2,12 +2,11 @@ | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Solver\User\UserMerchantSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class UserMerchantStore extends AbstractStore |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class UserPointSaleStore extends AbstractStore |
@@ -2,18 +2,20 @@ | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use App\Entity\Newsletter\Newsletter; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\StoreTrait; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
use Lc\SovBundle\Repository\User\UserStore as SovUserStore; | |||
class UserStore extends SovUserStore | |||
{ | |||
use StoreTrait; | |||
use MerchantStoreTrait; | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$query->filterByMerchant($this->merchant); | |||
$this->addFilterByMerchantOptionnal($query); | |||
return $query; | |||
} | |||
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\User; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class VisitorStore extends AbstractStore |
@@ -15,6 +15,7 @@ use Symfony\Component\Security\Core\Security; | |||
class SectionResolver | |||
{ | |||
protected bool $isCachedSection = false; | |||
protected ?SectionInterface $section = null; | |||
protected EntityManagerInterface $entityManager; | |||
@@ -44,7 +45,7 @@ class SectionResolver | |||
// admin | |||
if (isset($requestAttributesArray['easyadmin_context'])) { | |||
if ($this->section === null) { | |||
if (!$this->isCachedSection) { | |||
$currentAdminSection = null; | |||
$userMerchant = $this->merchantResolver->getUserMerchant(); | |||
@@ -52,7 +53,7 @@ class SectionResolver | |||
$currentAdminSection = $userMerchant->getCurrentAdminSection(); | |||
} | |||
if ($currentAdminSection === null) { | |||
/*if ($currentAdminSection === null) { | |||
$currentAdminSection = $this->sectionStore | |||
->setMerchant($userMerchant->getMerchant()) | |||
->getOneDefault(); | |||
@@ -60,8 +61,11 @@ class SectionResolver | |||
if ($currentAdminSection === null) { | |||
throw new \ErrorException('Aucune section par défaut définie pour ce merchant'); | |||
} | |||
} | |||
}*/ | |||
$this->isCachedSection = true; | |||
$this->section = $currentAdminSection; | |||
return $currentAdminSection; | |||
}else{ | |||
return $this->section; | |||
@@ -87,6 +91,11 @@ class SectionResolver | |||
} | |||
} | |||
public function isOutOfSection(): bool | |||
{ | |||
return $this->getCurrent() == null; | |||
} | |||
public function getDefault(): SectionInterface | |||
{ | |||
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault(); |
@@ -64,6 +64,7 @@ entity: | |||
taxRate: Règle de taxe | |||
merchants: Marchands | |||
sections: Sections | |||
section: Section | |||
behaviorTaxRate: Avec ou sans TVA | |||
behaviorTaxRateChoices: | |||
tax-excluded: TVA exclue | |||
@@ -185,6 +186,7 @@ entity: | |||
priceWithTax: Prix de vente | |||
sales: Historique des ventes | |||
propertyQualityLabelActive: Marquer le produit comme labellisé | |||
productFamilySectionProperties: Sections | |||
QualityLabel: | |||
label: Label de qualité |
@@ -2,4 +2,6 @@ | |||
{% import '@LcCaracole/admin/product/macro/product_family_macro.html.twig' as pfm %} | |||
{% set section_current = section_container.resolver.getCurrent() %} | |||
{{ pfm.product_family_sales_statistic(order_shop_container.builder.getProductsSalesStatistic(section_current, entity.instance, 2), entity.instance) }} | |||
{% if section_current %} | |||
{{ pfm.product_family_sales_statistic(order_shop_container.builder.getProductsSalesStatistic(section_current, entity.instance, 2), entity.instance) }} | |||
{% endif %} |
@@ -0,0 +1,7 @@ | |||
{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %} | |||
{% set item = entity.instance %} | |||
{% for section_property in item.productFamilySectionProperties %} | |||
{{ macros_section.section_badge(section_property.section) }} | |||
{% else %} | |||
<span class="badge badge-secondary">Aucune</span> | |||
{% endfor %} |
@@ -0,0 +1,7 @@ | |||
{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %} | |||
{% set item = entity.instance %} | |||
{% if item.section %} | |||
{{ macros_section.section_badge(item.section) }} | |||
{% else %} | |||
<span class="badge badge-secondary">Aucune</span> | |||
{% endif %} |
@@ -0,0 +1,7 @@ | |||
{% import '@LcCaracole/admin/section/macros.html.twig' as macros_section %} | |||
{% set item = entity.instance %} | |||
{% for section in item.sections %} | |||
{{ macros_section.section_badge(section) }} | |||
{% else %} | |||
<span class="badge badge-secondary">Aucune</span> | |||
{% endfor %} |
@@ -0,0 +1,4 @@ | |||
{% macro section_badge(section) %} | |||
<span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span> | |||
{% endmacro %} |
@@ -1,8 +1,8 @@ | |||
{% extends '@LcCaracole/adminlte/layout.html.twig' %} | |||
{% block content_title %} | |||
{% set current_section = resolver.getCurrent() %} | |||
Paramètres section > {{ current_section.title }} | |||
{% if resolver is defined %}{% set current_section = resolver.getCurrent() %}{% endif %} | |||
Paramètres section{% if current_section is defined and current_section %} > {{ current_section.title }}{% endif %} | |||
{% endblock %} | |||
{% block main %} |
@@ -6,17 +6,16 @@ | |||
{% set section_current = section_current() %} | |||
{% set is_display_switch_section = display_switch_section is defined and display_switch_section %} | |||
<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch section-{{ section_current.devAlias }}{% endif %}"> | |||
<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch {{ section_container.solver.getHtmlClass(section_current()) }}{% endif %}"> | |||
{% if is_display_switch_section %} | |||
<ul class="navbar-nav left"> | |||
<li class="nav-item d-none d-sm-inline-block"> | |||
{{ _self.form_switch_section(null) }} | |||
</li> | |||
{% for section in carac_sections() %} | |||
<li class="nav-item d-none d-sm-inline-block"> | |||
{% set form_switch_section = carac_form_switch_section(section) %} | |||
{% form_theme form_switch_section '@LcSov/adminlte/crud/form_theme.html.twig' %} | |||
{{ form_start(form_switch_section) }} | |||
{{ form(form_switch_section) }} | |||
{{ form_end(form_switch_section) }} | |||
{{ _self.form_switch_section(section) }} | |||
</li> | |||
{% endfor %} | |||
</ul> | |||
@@ -39,7 +38,6 @@ | |||
{% include '@LcSov/admin/reminder/block.html.twig' %} | |||
{% endblock %} | |||
{% block append_body %} | |||
{# modal switch merchant #} | |||
{% set user = app.user %} | |||
@@ -49,4 +47,12 @@ | |||
{# modal affichée uniquement si la sessionStorage.visit_merchant n'est pas défini (js) #} | |||
{% include '@LcCaracole/admin/merchant/modal/switch_merchant.html.twig' %} | |||
{% endif %} | |||
{% endblock %} | |||
{% endblock %} | |||
{% macro form_switch_section(section) %} | |||
{% set form_switch_section = carac_form_switch_section(section) %} | |||
{% form_theme form_switch_section '@LcSov/adminlte/crud/form_theme.html.twig' %} | |||
{{ form_start(form_switch_section) }} | |||
{{ form(form_switch_section) }} | |||
{{ form_end(form_switch_section) }} | |||
{% endmacro %} |
@@ -7,5 +7,11 @@ use Lc\CaracoleBundle\Model\Section\SectionModel; | |||
class SectionSolver | |||
{ | |||
public function getHtmlClass(?SectionInterface $section): string | |||
{ | |||
$htmlClass = 'section-'; | |||
$htmlClass .= $section ? $section->getDevAlias() : 'all'; | |||
return $htmlClass; | |||
} | |||
} |
@@ -106,7 +106,7 @@ class StoreTwigExtension extends AbstractExtension | |||
return $this->merchantStore->getOnline(); | |||
} | |||
public function getSectionCurrent(): SectionInterface | |||
public function getSectionCurrent(): ?SectionInterface | |||
{ | |||
return $this->sectionResolver->getCurrent(); | |||
} |