Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Fabien Normand 3 years ago
parent
commit
751eccedfd
98 changed files with 647 additions and 240 deletions
  1. +0
    -1
      Builder/Order/OrderShopBuilder.php
  2. +2
    -0
      Container/Address/AddressContainer.php
  3. +2
    -0
      Container/Config/TaxRateContainer.php
  4. +2
    -0
      Container/Credit/CreditHistoryContainer.php
  5. +2
    -0
      Container/File/DocumentContainer.php
  6. +2
    -0
      Container/Order/OrderShopContainer.php
  7. +2
    -0
      Container/PointSale/PointSaleContainer.php
  8. +12
    -1
      Container/Product/ProductCategoryContainer.php
  9. +2
    -0
      Container/Product/ProductContainer.php
  10. +2
    -0
      Container/Product/ProductFamilyContainer.php
  11. +2
    -0
      Container/Product/ProductFamilySectionPropertyContainer.php
  12. +11
    -1
      Container/Reduction/ReductionCartContainer.php
  13. +12
    -1
      Container/Reduction/ReductionCatalogContainer.php
  14. +2
    -0
      Container/Section/OpeningContainer.php
  15. +2
    -0
      Container/Section/SectionContainer.php
  16. +2
    -0
      Container/Setting/MerchantSettingContainer.php
  17. +2
    -0
      Container/Setting/SectionSettingContainer.php
  18. +2
    -0
      Container/User/UserMerchantContainer.php
  19. +2
    -2
      Context/SectionContextTrait.php
  20. +17
    -84
      Controller/AdminControllerTrait.php
  21. +8
    -1
      Controller/ControllerTrait.php
  22. +9
    -3
      Controller/Newsletter/NewsletterAdminController.php
  23. +4
    -17
      Controller/Product/ProductCategoryAdminController.php
  24. +22
    -11
      Controller/Section/OpeningAdminController.php
  25. +0
    -1
      Controller/Section/SectionAdminController.php
  26. +9
    -3
      Controller/Section/SwitchSectionAdminController.php
  27. +19
    -18
      Controller/Setting/SettingAdminController.php
  28. +2
    -2
      Controller/Site/NewsAdminController.php
  29. +3
    -3
      Controller/Site/PageAdminController.php
  30. +10
    -0
      Definition/Field/AbstractFieldDefinition.php
  31. +46
    -0
      Definition/Field/FieldDefinitionTrait.php
  32. +36
    -0
      Definition/Field/Newsletter/NewsletterFieldDefinition.php
  33. +11
    -1
      Definition/Field/Order/OrderShopFieldDefinition.php
  34. +79
    -0
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  35. +27
    -0
      Definition/Field/Reduction/ReductionCartFieldDefinition.php
  36. +27
    -0
      Definition/Field/Reduction/ReductionCatalogFieldDefinition.php
  37. +31
    -0
      Definition/Field/Site/NewsFieldDefinition.php
  38. +30
    -0
      Definition/Field/Site/PageFieldDefinition.php
  39. +2
    -0
      Factory/Site/PageFactory.php
  40. +3
    -0
      Field/AssociationField.php
  41. +10
    -7
      Form/Section/SwitchSectionFormType.php
  42. +21
    -3
      Model/Site/PageModel.php
  43. +10
    -0
      Repository/AbstractStore.php
  44. +1
    -1
      Repository/Address/AddressStore.php
  45. +1
    -3
      Repository/Config/TaxRateStore.php
  46. +1
    -1
      Repository/Config/UnitStore.php
  47. +1
    -1
      Repository/Credit/CreditHistoryStore.php
  48. +1
    -3
      Repository/Distribution/DistributionStore.php
  49. +1
    -1
      Repository/File/DocumentStore.php
  50. +1
    -2
      Repository/Merchant/MerchantStore.php
  51. +2
    -2
      Repository/MerchantStoreTrait.php
  52. +2
    -0
      Repository/Newsletter/NewsletterStore.php
  53. +1
    -1
      Repository/Order/OrderPaymentStore.php
  54. +1
    -1
      Repository/Order/OrderProductReductionCatalogStore.php
  55. +1
    -1
      Repository/Order/OrderProductRefundStore.php
  56. +1
    -1
      Repository/Order/OrderProductStore.php
  57. +1
    -1
      Repository/Order/OrderReductionCartStore.php
  58. +1
    -1
      Repository/Order/OrderReductionCreditStore.php
  59. +1
    -1
      Repository/Order/OrderRefundStore.php
  60. +1
    -1
      Repository/Order/OrderShopStore.php
  61. +1
    -1
      Repository/Order/OrderStatusHistoryStore.php
  62. +1
    -1
      Repository/Order/OrderStatusStore.php
  63. +1
    -1
      Repository/PointSale/PointSaleStore.php
  64. +1
    -1
      Repository/Product/ProductCategoryStore.php
  65. +1
    -1
      Repository/Product/ProductFamilySectionPropertyStore.php
  66. +1
    -1
      Repository/Product/ProductFamilyStore.php
  67. +3
    -2
      Repository/Product/ProductStore.php
  68. +1
    -1
      Repository/Product/QualityLabelStore.php
  69. +1
    -5
      Repository/Reduction/ReductionCartStore.php
  70. +1
    -1
      Repository/Reduction/ReductionCatalogStore.php
  71. +1
    -5
      Repository/Reduction/ReductionCreditStore.php
  72. +2
    -1
      Repository/Reminder/ReminderStore.php
  73. +1
    -2
      Repository/Section/OpeningStore.php
  74. +1
    -2
      Repository/Section/SectionStore.php
  75. +1
    -1
      Repository/SectionStoreTrait.php
  76. +1
    -1
      Repository/Setting/MerchantSettingStore.php
  77. +1
    -1
      Repository/Setting/SectionSettingStore.php
  78. +3
    -1
      Repository/Site/NewsStore.php
  79. +2
    -1
      Repository/Site/PageRepositoryQuery.php
  80. +7
    -3
      Repository/Site/PageStore.php
  81. +17
    -0
      Repository/StoreTrait.php
  82. +3
    -2
      Repository/Ticket/TicketStore.php
  83. +3
    -2
      Repository/User/GroupUserStore.php
  84. +1
    -2
      Repository/User/UserMerchantStore.php
  85. +1
    -1
      Repository/User/UserPointSaleStore.php
  86. +4
    -2
      Repository/User/UserStore.php
  87. +1
    -1
      Repository/User/VisitorStore.php
  88. +12
    -3
      Resolver/SectionResolver.php
  89. +2
    -0
      Resources/translations/admin.fr.yaml
  90. +3
    -1
      Resources/views/admin/product/field/product_family_sales.html.twig
  91. +7
    -0
      Resources/views/admin/product/field/product_family_section_properties.html.twig
  92. +7
    -0
      Resources/views/admin/section/field/section.html.twig
  93. +7
    -0
      Resources/views/admin/section/field/sections.html.twig
  94. +4
    -0
      Resources/views/admin/section/macros.html.twig
  95. +2
    -2
      Resources/views/admin/setting/edit_section.html.twig
  96. +14
    -8
      Resources/views/adminlte/layout.html.twig
  97. +6
    -0
      Solver/Section/SectionSolver.php
  98. +1
    -1
      Twig/StoreTwigExtension.php

+ 0
- 1
Builder/Order/OrderShopBuilder.php View File

@@ -646,7 +646,6 @@ class OrderShopBuilder
$orderShop->setDeclineComplementaryOrderShop(false);
}


public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2)
{
$productsSalesStatistic = new ProductsSalesStatistic(

+ 2
- 0
Container/Address/AddressContainer.php View File

@@ -47,6 +47,8 @@ class AddressContainer

public function getStore(): AddressStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/Config/TaxRateContainer.php View File

@@ -34,6 +34,8 @@ class TaxRateContainer

public function getStore(): TaxRateStore
{
$this->store->resetContext();

return $this->store;
}
}

+ 2
- 0
Container/Credit/CreditHistoryContainer.php View File

@@ -51,6 +51,8 @@ class CreditHistoryContainer

public function getStore(): CreditHistoryStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/File/DocumentContainer.php View File

@@ -34,6 +34,8 @@ class DocumentContainer

public function getStore(): DocumentStore
{
$this->store->resetContext();

return $this->store;
}
}

+ 2
- 0
Container/Order/OrderShopContainer.php View File

@@ -59,6 +59,8 @@ class OrderShopContainer

public function getStore(): OrderShopStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/PointSale/PointSaleContainer.php View File

@@ -52,6 +52,8 @@ class PointSaleContainer

public function getStore(): PointSaleStore
{
$this->store->resetContext();

return $this->store;
}
}

+ 12
- 1
Container/Product/ProductCategoryContainer.php View File

@@ -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;
}

}

+ 2
- 0
Container/Product/ProductContainer.php View File

@@ -43,6 +43,8 @@ class ProductContainer

public function getStore(): ProductStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/Product/ProductFamilyContainer.php View File

@@ -55,6 +55,8 @@ class ProductFamilyContainer

public function getStore(): ProductFamilyStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/Product/ProductFamilySectionPropertyContainer.php View File

@@ -54,6 +54,8 @@ class ProductFamilySectionPropertyContainer

public function getStore(): ProductFamilySectionPropertyStore
{
$this->store->resetContext();

return $this->store;
}


+ 11
- 1
Container/Reduction/ReductionCartContainer.php View File

@@ -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;
}
}

+ 12
- 1
Container/Reduction/ReductionCatalogContainer.php View File

@@ -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;
}

}

+ 2
- 0
Container/Section/OpeningContainer.php View File

@@ -43,6 +43,8 @@ class OpeningContainer

public function getStore(): OpeningStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/Section/SectionContainer.php View File

@@ -52,6 +52,8 @@ class SectionContainer

public function getStore(): SectionStore
{
$this->store->resetContext();

return $this->store;
}
}

+ 2
- 0
Container/Setting/MerchantSettingContainer.php View File

@@ -47,6 +47,8 @@ class MerchantSettingContainer

public function getStore(): MerchantSettingStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/Setting/SectionSettingContainer.php View File

@@ -47,6 +47,8 @@ class SectionSettingContainer

public function getStore(): SectionSettingStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 0
Container/User/UserMerchantContainer.php View File

@@ -51,6 +51,8 @@ class UserMerchantContainer

public function getStore(): UserMerchantStore
{
$this->store->resetContext();

return $this->store;
}


+ 2
- 2
Context/SectionContextTrait.php View File

@@ -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;


+ 17
- 84
Controller/AdminControllerTrait.php View File

@@ -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;

+ 8
- 1
Controller/ControllerTrait.php View File

@@ -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();
}

+ 9
- 3
Controller/Newsletter/NewsletterAdminController.php View File

@@ -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);
}
}

+ 4
- 17
Controller/Product/ProductCategoryAdminController.php View File

@@ -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);
}

}

+ 22
- 11
Controller/Section/OpeningAdminController.php View File

@@ -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;
}
}

+ 0
- 1
Controller/Section/SectionAdminController.php View File

@@ -17,7 +17,6 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class SectionAdminController extends AbstractAdminController
{

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(SectionContainer::class)->getRepositoryQuery();

+ 9
- 3
Controller/Section/SwitchSectionAdminController.php View File

@@ -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();
}
}

+ 19
- 18
Controller/Setting/SettingAdminController.php View File

@@ -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
- 2
Controller/Site/NewsAdminController.php View File

@@ -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)
{

+ 3
- 3
Controller/Site/PageAdminController.php View File

@@ -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();
}

+ 10
- 0
Definition/Field/AbstractFieldDefinition.php View File

@@ -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;
}

+ 46
- 0
Definition/Field/FieldDefinitionTrait.php View File

@@ -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);
}
}

+ 36
- 0
Definition/Field/Newsletter/NewsletterFieldDefinition.php View File

@@ -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());
}
}

+ 11
- 1
Definition/Field/Order/OrderShopFieldDefinition.php View File

@@ -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'];

+ 79
- 0
Definition/Field/Product/ProductCategoryFieldDefinition.php View File

@@ -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),
];
}
}

+ 27
- 0
Definition/Field/Reduction/ReductionCartFieldDefinition.php View File

@@ -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
];
}
}

+ 27
- 0
Definition/Field/Reduction/ReductionCatalogFieldDefinition.php View File

@@ -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
];
}
}

+ 31
- 0
Definition/Field/Site/NewsFieldDefinition.php View File

@@ -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());
}
}

+ 30
- 0
Definition/Field/Site/PageFieldDefinition.php View File

@@ -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'
];
}
}

+ 2
- 0
Factory/Site/PageFactory.php View File

@@ -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;

+ 3
- 0
Field/AssociationField.php View File

@@ -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;

+ 10
- 7
Form/Section/SwitchSectionFormType.php View File

@@ -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,

+ 21
- 3
Model/Site/PageModel.php View File

@@ -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;
}

}

+ 10
- 0
Repository/AbstractStore.php View File

@@ -0,0 +1,10 @@
<?php

namespace Lc\CaracoleBundle\Repository;

Use Lc\SovBundle\Repository\AbstractStore as SovAbstractStore;

abstract class AbstractStore extends SovAbstractStore
{
use StoreTrait;
}

+ 1
- 1
Repository/Address/AddressStore.php View File

@@ -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

+ 1
- 3
Repository/Config/TaxRateStore.php View File

@@ -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

+ 1
- 1
Repository/Config/UnitStore.php View File

@@ -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

+ 1
- 1
Repository/Credit/CreditHistoryStore.php View File

@@ -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;


+ 1
- 3
Repository/Distribution/DistributionStore.php View File

@@ -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

+ 1
- 1
Repository/File/DocumentStore.php View File

@@ -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

+ 1
- 2
Repository/Merchant/MerchantStore.php View File

@@ -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

+ 2
- 2
Repository/MerchantStoreTrait.php View File

@@ -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;


+ 2
- 0
Repository/Newsletter/NewsletterStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderPaymentStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderProductReductionCatalogStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderProductRefundStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderProductStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderReductionCartStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderReductionCreditStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderRefundStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderShopStore.php View File

@@ -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;

+ 1
- 1
Repository/Order/OrderStatusHistoryStore.php View File

@@ -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

+ 1
- 1
Repository/Order/OrderStatusStore.php View File

@@ -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

+ 1
- 1
Repository/PointSale/PointSaleStore.php View File

@@ -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

+ 1
- 1
Repository/Product/ProductCategoryStore.php View File

@@ -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

+ 1
- 1
Repository/Product/ProductFamilySectionPropertyStore.php View File

@@ -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

+ 1
- 1
Repository/Product/ProductFamilyStore.php View File

@@ -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
- 2
Repository/Product/ProductStore.php View File

@@ -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;
}


+ 1
- 1
Repository/Product/QualityLabelStore.php View File

@@ -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

+ 1
- 5
Repository/Reduction/ReductionCartStore.php View File

@@ -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
{

+ 1
- 1
Repository/Reduction/ReductionCatalogStore.php View File

@@ -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

+ 1
- 5
Repository/Reduction/ReductionCreditStore.php View File

@@ -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

+ 2
- 1
Repository/Reminder/ReminderStore.php View File

@@ -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;


+ 1
- 2
Repository/Section/OpeningStore.php View File

@@ -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

+ 1
- 2
Repository/Section/SectionStore.php View File

@@ -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;


+ 1
- 1
Repository/SectionStoreTrait.php View File

@@ -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;


+ 1
- 1
Repository/Setting/MerchantSettingStore.php View File

@@ -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

+ 1
- 1
Repository/Setting/SectionSettingStore.php View File

@@ -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
- 1
Repository/Site/NewsStore.php View File

@@ -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
- 1
Repository/Site/PageRepositoryQuery.php View File

@@ -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;

}

+ 7
- 3
Repository/Site/PageStore.php View File

@@ -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);
}


+ 17
- 0
Repository/StoreTrait.php View File

@@ -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
- 2
Repository/Ticket/TicketStore.php View File

@@ -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
- 2
Repository/User/GroupUserStore.php View File

@@ -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);
}

}

+ 1
- 2
Repository/User/UserMerchantStore.php View File

@@ -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

+ 1
- 1
Repository/User/UserPointSaleStore.php View File

@@ -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

+ 4
- 2
Repository/User/UserStore.php View File

@@ -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;
}


+ 1
- 1
Repository/User/VisitorStore.php View File

@@ -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

+ 12
- 3
Resolver/SectionResolver.php View File

@@ -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();

+ 2
- 0
Resources/translations/admin.fr.yaml View File

@@ -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é

+ 3
- 1
Resources/views/admin/product/field/product_family_sales.html.twig View File

@@ -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 %}

+ 7
- 0
Resources/views/admin/product/field/product_family_section_properties.html.twig View File

@@ -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 %}

+ 7
- 0
Resources/views/admin/section/field/section.html.twig View File

@@ -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 %}

+ 7
- 0
Resources/views/admin/section/field/sections.html.twig View File

@@ -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 %}

+ 4
- 0
Resources/views/admin/section/macros.html.twig View File

@@ -0,0 +1,4 @@

{% macro section_badge(section) %}
<span class="badge badge-secondary {{ section_container.solver.getHtmlClass(section) }}">{{ section.title }}</span>
{% endmacro %}

+ 2
- 2
Resources/views/admin/setting/edit_section.html.twig View File

@@ -1,8 +1,8 @@
{% extends '@LcCaracole/adminlte/layout.html.twig' %}

{% block content_title %}
{% set current_section = resolver.getCurrent() %}
Paramètres section &gt; {{ current_section.title }}
{% if resolver is defined %}{% set current_section = resolver.getCurrent() %}{% endif %}
Paramètres section{% if current_section is defined and current_section %} &gt; {{ current_section.title }}{% endif %}
{% endblock %}

{% block main %}

+ 14
- 8
Resources/views/adminlte/layout.html.twig View File

@@ -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 %}

+ 6
- 0
Solver/Section/SectionSolver.php View File

@@ -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;
}
}

+ 1
- 1
Twig/StoreTwigExtension.php View File

@@ -106,7 +106,7 @@ class StoreTwigExtension extends AbstractExtension
return $this->merchantStore->getOnline();
}

public function getSectionCurrent(): SectionInterface
public function getSectionCurrent(): ?SectionInterface
{
return $this->sectionResolver->getCurrent();
}

Loading…
Cancel
Save