Guillaume 3 лет назад
Родитель
Сommit
1cadf0ee96
100 измененных файлов: 6392 добавлений и 99 удалений
  1. +69
    -0
      Builder/Address/AddressBuilder.php
  2. +93
    -0
      Builder/Credit/CreditHistoryBuilder.php
  3. +8
    -0
      Builder/Distribution/DistributionBuilder.php
  4. +39
    -0
      Builder/File/DocumentBuilder.php
  5. +37
    -0
      Builder/Merchant/MerchantBuilder.php
  6. +50
    -0
      Builder/Order/OrderProductBuilder.php
  7. +671
    -0
      Builder/Order/OrderShopBuilder.php
  8. +8
    -0
      Builder/Product/ProductFamilyBuilder.php
  9. +49
    -0
      Builder/Product/ProductFamilySectionPropertyBuilder.php
  10. +82
    -0
      Builder/Reduction/ReductionCreditBuilder.php
  11. +132
    -0
      Builder/Setting/SettingBuilder.php
  12. +20
    -0
      Builder/Ticket/TicketBuilder.php
  13. +29
    -0
      Builder/User/UserBuilder.php
  14. +105
    -0
      Builder/User/UserMerchantBuilder.php
  15. +77
    -0
      Builder/User/VisitorBuilder.php
  16. +34
    -0
      Command/MerchantSettingInitCommand.php
  17. +34
    -0
      Command/SectionSettingInitCommand.php
  18. +59
    -0
      Container/Address/AddressContainer.php
  19. +41
    -0
      Container/Config/TaxRateContainer.php
  20. +39
    -0
      Container/Config/UnitContainer.php
  21. +68
    -0
      Container/Credit/CreditHistoryContainer.php
  22. +59
    -0
      Container/Distribution/DistributionContainer.php
  23. +41
    -0
      Container/File/DocumentContainer.php
  24. +67
    -0
      Container/Merchant/MerchantContainer.php
  25. +39
    -0
      Container/Order/OrderPaymentContainer.php
  26. +57
    -0
      Container/Order/OrderProductContainer.php
  27. +49
    -0
      Container/Order/OrderProductReductionCatalogContainer.php
  28. +40
    -0
      Container/Order/OrderProductRefundContainer.php
  29. +40
    -0
      Container/Order/OrderReductionCartContainer.php
  30. +40
    -0
      Container/Order/OrderReductionCreditContainer.php
  31. +40
    -0
      Container/Order/OrderRefundContainer.php
  32. +87
    -0
      Container/Order/OrderShopContainer.php
  33. +40
    -0
      Container/Order/OrderStatusContainer.php
  34. +40
    -0
      Container/Order/OrderStatusHistoryContainer.php
  35. +59
    -0
      Container/PointSale/PointSaleContainer.php
  36. +60
    -0
      Container/Product/ProductCategoryContainer.php
  37. +51
    -0
      Container/Product/ProductContainer.php
  38. +78
    -0
      Container/Product/ProductFamilyContainer.php
  39. +66
    -0
      Container/Product/ProductFamilySectionPropertyContainer.php
  40. +40
    -0
      Container/Product/QualityLabelContainer.php
  41. +50
    -0
      Container/Reduction/ReductionCartContainer.php
  42. +51
    -0
      Container/Reduction/ReductionCatalogContainer.php
  43. +49
    -0
      Container/Reduction/ReductionCreditContainer.php
  44. +51
    -0
      Container/Section/OpeningContainer.php
  45. +59
    -0
      Container/Section/SectionContainer.php
  46. +60
    -0
      Container/Setting/MerchantSettingContainer.php
  47. +60
    -0
      Container/Setting/SectionSettingContainer.php
  48. +69
    -0
      Container/User/UserMerchantContainer.php
  49. +40
    -0
      Container/User/UserPointSaleContainer.php
  50. +67
    -0
      Container/User/VisitorContainer.php
  51. +17
    -0
      Context/MerchantContextTrait.php
  52. +17
    -0
      Context/SectionContextTrait.php
  53. +10
    -0
      Controller/AbstractAdminController.php
  54. +10
    -0
      Controller/AbstractController.php
  55. +92
    -0
      Controller/Address/AddressApiController.php
  56. +275
    -0
      Controller/AdminControllerTrait.php
  57. +0
    -35
      Controller/Common/TaxRateCrudController.php
  58. +40
    -0
      Controller/Config/TaxRateAdminController.php
  59. +41
    -0
      Controller/Config/UnitAdminController.php
  60. +356
    -0
      Controller/ControllerTrait.php
  61. +127
    -0
      Controller/Credit/CreditHistoryAdminController.php
  62. +49
    -0
      Controller/Dashboard/DashboardAdminAdminController.php
  63. +48
    -0
      Controller/Merchant/FavoriteMerchantController.php
  64. +59
    -0
      Controller/Merchant/MerchantAdminController.php
  65. +43
    -0
      Controller/Merchant/SwitchMerchantController.php
  66. +28
    -0
      Controller/Newsletter/NewsletterAdminController.php
  67. +178
    -0
      Controller/Order/CartController.php
  68. +25
    -0
      Controller/Order/OrderShopAdminController.php
  69. +23
    -0
      Controller/Order/OrderStatusAdminController.php
  70. +32
    -0
      Controller/PointSale/PointSaleAdminController.php
  71. +101
    -0
      Controller/Product/FavoriteController.php
  72. +49
    -0
      Controller/Product/ProductCategoryAdminController.php
  73. +67
    -0
      Controller/Product/ProductFamilyAdminController.php
  74. +32
    -0
      Controller/Product/QualityLabelAdminController.php
  75. +22
    -0
      Controller/Reduction/ReductionCartAdminController.php
  76. +19
    -0
      Controller/Reduction/ReductionCatalogAdminController.php
  77. +20
    -0
      Controller/Reduction/ReductionCreditAdminController.php
  78. +22
    -0
      Controller/Reminder/ReminderAdminController.php
  79. +77
    -0
      Controller/Section/OpeningAdminController.php
  80. +64
    -0
      Controller/Section/SectionAdminController.php
  81. +50
    -0
      Controller/Section/SwitchSectionAdminController.php
  82. +113
    -0
      Controller/Setting/SettingAdminController.php
  83. +19
    -0
      Controller/Site/NewsAdminController.php
  84. +20
    -0
      Controller/Site/PageAdminController.php
  85. +45
    -0
      Controller/Ticket/TicketAdminController.php
  86. +19
    -0
      Controller/User/GroupUserAdminController.php
  87. +0
    -64
      Controller/User/GroupUserCrudController.php
  88. +46
    -0
      Controller/User/UserAdminController.php
  89. +236
    -0
      Controller/User/UserMerchantAdminController.php
  90. +129
    -0
      Definition/AbstractSettingDefinition.php
  91. +13
    -0
      Definition/ActionDefinition.php
  92. +10
    -0
      Definition/Field/AbstractFieldDefinition.php
  93. +80
    -0
      Definition/Field/Credit/CreditHistoryFieldDefinition.php
  94. +46
    -0
      Definition/Field/FieldDefinitionTrait.php
  95. +36
    -0
      Definition/Field/Newsletter/NewsletterFieldDefinition.php
  96. +89
    -0
      Definition/Field/Order/OrderShopFieldDefinition.php
  97. +65
    -0
      Definition/Field/PointSale/PointSaleFieldDefinition.php
  98. +86
    -0
      Definition/Field/Product/ProductCategoryFieldDefinition.php
  99. +27
    -0
      Definition/Field/Reduction/ReductionCartFieldDefinition.php
  100. +27
    -0
      Definition/Field/Reduction/ReductionCatalogFieldDefinition.php

+ 69
- 0
Builder/Address/AddressBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Address;

use App\Entity\Address\Address;
use App\Repository\Order\OrderShopStore;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Repository\File\DocumentStore;

class AddressBuilder
{
protected EntityManagerInterface $entityManager;
protected OrderShopStore $orderShopStore;
protected DocumentStore $documentStore;

public function __construct(
EntityManagerInterface $entityManager,
OrderShopStore $orderShopStore,
DocumentStore $documentStore
) {
$this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore;
$this->documentStore = $documentStore;
}

// unlinkAddress
public function unlink(Address $address): void
{
$orderShops = $this->orderShopStore->getBy(
[
'address' => $address
]
);

if ($orderShops) {
foreach ($orderShops as $orderShop) {
$update = false;
if ($orderShop->getInvoiceAddress() == $address) {
$orderShop->setInvoiceAddress(null);
$update = true;
}
if ($orderShop->getDeliveryAddress() == $address) {
$orderShop->setDeliveryAddress(null);
$update = true;
}
if ($update) {
$this->entityManager->update($orderShop);
}
}
}

$documents = $this->documentStore->getByBuyerAddress($address);

if ($documents) {
foreach ($documents as $document) {
$update = false;
if ($document->getBuyerAddress() == $address) {
$document->setBuyerAddress(null);
$update = true;
}
if ($update) {
$this->entityManager->update($document);
}
}
}

$this->entityManager->flush();
}
}

+ 93
- 0
Builder/Credit/CreditHistoryBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Credit;

use Lc\CaracoleBundle\Builder\User\UserMerchantBuilder;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\User\UserMerchantStore;
use Lc\CaracoleBundle\Solver\Credit\CreditHistorySolver;
use Lc\CaracoleBundle\Solver\User\UserMerchantSolver;

class CreditHistoryBuilder
{
protected CreditHistoryFactory $creditHistoryFactory;
protected CreditHistorySolver $creditHistorySolver;
protected UserMerchantSolver $userMerchantSolver;
protected UserMerchantStore $userMerchantStore;
protected UserMerchantBuilder $userMerchantBuilder;

public function __construct(
CreditHistoryFactory $creditHistoryFactory,
CreditHistorySolver $creditHistorySolver,
UserMerchantStore $userMerchantStore,
UserMerchantBuilder $userMerchantBuilder,
UserMerchantSolver $userMerchantSolver
) {
$this->creditHistoryFactory = $creditHistoryFactory;
$this->creditHistorySolver = $creditHistorySolver;
$this->userMerchantStore = $userMerchantStore;
$this->userMerchantBuilder = $userMerchantBuilder;
$this->userMerchantSolver = $userMerchantSolver;
}

public function create(
string $type,
UserMerchantInterface $userMerchant,
array $params = []
): CreditHistoryInterface {
$creditHistory = $this->creditHistoryFactory->create($type, $userMerchant);

$amount = isset($params['amount']) ? $params['amount'] : null ;
$meanPayment = isset($params['meanPayment']) ? $params['meanPayment'] : null ;
$reference = isset($params['reference']) ? $params['reference'] : null ;
$comment = isset($params['comment']) ? $params['comment'] : null ;
$orderPayment = isset($params['orderPayment']) ? $params['orderPayment'] : null ;
$orderRefund = isset($params['orderRefund']) ? $params['orderRefund'] : null ;

$creditHistory->setType($type);
$creditHistory->setUserMerchant($userMerchant);
$creditHistory->setAmount($amount);
$creditHistory->setMeanPayment($meanPayment);
$creditHistory->setReference($reference);
$creditHistory->setComment($comment);
$creditHistory->setOrderPayment($orderPayment);
$creditHistory->setOrderRefund($orderRefund);

$this->save($creditHistory);

return $creditHistory;
}

// saveCreditHistory
public function save(CreditHistoryInterface $creditHistory): bool
{
$amount = $this->creditHistorySolver->getAmountInherited($creditHistory);
$userMerchant = $creditHistory->getUserMerchant();
$isCreditActive = $this->userMerchantSolver->isCreditActive($userMerchant);

if ($isCreditActive) {
if ($creditHistory->getType() == CreditHistoryModel::TYPE_CREDIT) {
$userMerchantAmount = $userMerchant->getCredit() + $amount;
$this->userMerchantBuilder->updateCredit($userMerchant, $creditHistory, $userMerchantAmount);
return true;
} elseif ($creditHistory->getType() == CreditHistoryModel::TYPE_DEBIT) {
if ($this->userMerchantSolver->isCreditSufficientToPay(
$userMerchant,
$amount
)) {
$userMerchantAmount = $userMerchant->getCredit() - $amount;
$this->userMerchantBuilder->updateCredit($userMerchant, $creditHistory, $userMerchantAmount);
return true;
} else {
return false;
}
}
}

return false;
}

}

+ 8
- 0
Builder/Distribution/DistributionBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Distribution;

class DistributionBuilder
{

}

+ 39
- 0
Builder/File/DocumentBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\File;

use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;
use Lc\CaracoleBundle\Solver\Address\AddressSolver;

class DocumentBuilder
{
protected DocumentReferenceGenerator $documentReferenceGenerator;
protected AddressSolver $addressSolver;

public function __construct(DocumentReferenceGenerator $documentReferenceGenerator, AddressSolver $addressSolver)
{
$this->documentReferenceGenerator = $documentReferenceGenerator;
$this->addressSolver = $addressSolver;
}

public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface
{
$merchantAddress = $orderShop->getSection()->getMerchant()->getAddress();
$buyerAddress = $orderShop->getInvoiceAddress();
//TODO a discuter, doit on garder le lien avec merchant pr la référence ou le mettre par section ? Est-ce que le nom de cette fonction est approprié. on fait une invoice et ça s'appele initFromOrderShop
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getSection()->getMerchant(), $document->getType())) ;

$document->setMerchantAddress($merchantAddress);
$document->setBuyerAddress($buyerAddress);
$document->setMerchantAddressText($this->addressSolver->getSummary($merchantAddress));
$document->setBuyerAddressText($this->addressSolver->getSummary($buyerAddress));
$document->addOrderShop($orderShop);
$document->setCreatedBy($orderShop->getUser());

return $document;
}

}

+ 37
- 0
Builder/Merchant/MerchantBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Merchant;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Component\CookieComponent;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Cookie;

class MerchantBuilder
{
protected ParameterBagInterface $parameterBag;
protected CookieComponent $cookieComponent;

public function __construct(
ParameterBagInterface $parameterBag,
CookieComponent $cookieComponent
) {
$this->parameterBag = $parameterBag;
$this->cookieComponent = $cookieComponent;
}

public function setCookieMerchantCurrent($response, MerchantInterface $merchant) :void
{
$response->headers->setCookie(
Cookie::create(
$this->parameterBag->get('app.cookie_name_merchant_current'),
$merchant->getId(),
0,
'/',
$this->cookieComponent->getCookieDomain()
)
);
}

}

+ 50
- 0
Builder/Order/OrderProductBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Order;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
use Lc\CaracoleBundle\Solver\Order\OrderProductSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;

class OrderProductBuilder
{
protected EntityManagerInterface $entityManager;
protected PriceSolver $priceSolver;
protected OrderProductStore $orderProductStore;
protected ProductSolver $productSolver;
protected ProductFamilySolver $productFamilySolver;
protected OrderProductSolver $orderProductSolver;

public function __construct(
EntityManagerInterface $entityManager,
PriceSolver $priceSolver,
OrderProductStore $orderProductStore,
ProductSolver $productSolver,
OrderProductSolver $orderProductSolver,
ProductFamilySolver $productFamilySolver
) {
$this->entityManager = $entityManager;
$this->priceSolver = $priceSolver;
$this->orderProductStore = $orderProductStore;
$this->productSolver = $productSolver;
$this->orderProductSolver = $orderProductSolver;
$this->productFamilySolver = $productFamilySolver;
}

public function init(OrderProductInterface $orderProduct) :OrderProductInterface
{
$orderProduct->setTitle($this->orderProductSolver->getTitleOrderShop($orderProduct));
$orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct()));
$orderProduct->setBuyingPrice($this->priceSolver->getBuyingPrice($orderProduct->getProduct()));
$orderProduct->setUnit($this->productSolver->getUnitInherited($orderProduct->getProduct()));
$orderProduct->setTaxRate($this->productFamilySolver->getTaxRateInherited($orderProduct->getProduct()));
$orderProduct->setQuantityProduct($this->productSolver->getQuantityInherited($orderProduct->getProduct()));

return $orderProduct;
}
}

+ 671
- 0
Builder/Order/OrderShopBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Order;

use App\Builder\Distribution\DistributionBuilder;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder;
use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Factory\File\DocumentFactory;
use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory;
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory;
use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory;
use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory;
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory;
use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Order\OrderPaymentModel;
use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface;
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
use Lc\CaracoleBundle\Resolver\OrderShopResolver;
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;
use Lc\CaracoleBundle\Statistic\Product\ProductsSalesStatistic;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\FlashBagTranslator;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface;

class OrderShopBuilder
{
protected EntityManagerInterface $entityManager;
protected OrderStatusStore $orderStatusStore;
protected OrderProductStore $orderProductStore;
protected OrderShopStore $orderShopStore;
protected OrderShopSolver $orderShopSolver;
protected ProductFamilyStore $productFamilyStore;
protected PriceSolver $priceSolver;
protected OrderProductBuilder $orderProductBuilder;
protected DocumentBuilder $documentBuilder;
protected EventDispatcherInterface $eventDispatcher;
protected FlashBagInterface $flashBag;
protected OpeningResolver $openingResolver;
protected ProductSolver $productSolver;
protected OrderShopResolver $orderShopResolver;
protected OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver;
protected DistributionBuilder $distributionBuilder;
protected MerchantResolver $merchantResolver;
protected CreditHistoryBuilder $creditHistoryBuilder;

public function __construct(
EntityManagerInterface $entityManager,
OrderShopStore $orderShopStore,
OrderShopSolver $orderShopSolver,
OrderStatusStore $orderStatusStore,
OrderProductStore $orderProductStore,
ProductFamilyStore $productFamilyStore,
OrderProductBuilder $orderProductBuilder,
DocumentBuilder $documentBuilder,
PriceSolver $priceSolver,
EventDispatcherInterface $eventDispatcher,
FlashBagInterface $flashBag,
OpeningResolver $openingResolver,
ProductSolver $productSolver,
OrderShopResolver $orderShopResolver,
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver,
DistributionBuilder $distributionBuilder,
MerchantResolver $merchantResolver,
CreditHistoryBuilder $creditHistoryBuilder
) {
$this->entityManager = $entityManager;
$this->orderShopStore = $orderShopStore;
$this->orderShopSolver = $orderShopSolver;
$this->orderStatusStore = $orderStatusStore;
$this->orderProductStore = $orderProductStore;
$this->productFamilyStore = $productFamilyStore;
$this->orderProductBuilder = $orderProductBuilder;
$this->documentBuilder = $documentBuilder;
$this->priceSolver = $priceSolver;
$this->eventDispatcher = $eventDispatcher;
$this->flashBag = $flashBag;
$this->openingResolver = $openingResolver;
$this->productSolver = $productSolver;
$this->orderShopResolver = $orderShopResolver;
$this->orderProductReductionCatalogSolver = $orderProductReductionCatalogSolver;
$this->distributionBuilder = $distributionBuilder;
$this->merchantResolver = $merchantResolver;
$this->creditHistoryBuilder = $creditHistoryBuilder;
}

public function create(
SectionInterface $section,
UserInterface $user = null,
VisitorInterface $visitor = null
): OrderShopInterface {
$orderShopFactory = new OrderShopFactory();
$orderShop = $orderShopFactory->create($section, $user, $visitor);

$this->setOrderStatus($orderShop, OrderStatusModel::ALIAS_CART);

$this->entityManager->create($orderShop);
$this->entityManager->flush();

return $orderShop;
}


protected array $cacheCartCurrentBySection = [];

public function createIfNotExist(
SectionInterface $section,
UserInterface $user = null,
VisitorInterface $visitor = null,
bool $cache = false
): OrderShopInterface {

$cart = null;

// cache
$cacheIdCartCurrent = 'cart_current_'.$section->getId();
if($cache
&& isset($this->cacheCartCurrentBySection[$cacheIdCartCurrent])
&& $this->cacheCartCurrentBySection[$cacheIdCartCurrent]) {

return $this->cacheCartCurrentBySection[$cacheIdCartCurrent];
}

$this->orderShopStore->setSection($section);

$cartUser = $this->orderShopStore->getOneCartCurrent($user);
$cartVisitor = $this->orderShopStore->getOneCartCurrent(null, $visitor);

if ($cartUser && $cartVisitor && $cartUser->getId() != $cartVisitor->getId()) {
$cart = $this->merge($cartUser, $cartVisitor);
} else {
if($cartUser) {
$cart = $cartUser;
}
elseif($cartVisitor) {

if($user && $cartVisitor && !$cartVisitor->getUser()) {
$cartVisitor->setUser($user);
$this->entityManager->update($cartVisitor);
$this->entityManager->flush();
}

$cart = $cartVisitor;
}
}

if (!$cart) {
$cart = $this->create($section, $user, $visitor);
}

// @TODO : obligé de faire ça sinon le panier ne se met pas à jour quand on ajoute des produits. Pourquoi ?
$this->entityManager->refresh($cart);

// cache
$this->cacheCartCurrentBySection[$cacheIdCartCurrent] = $cart;

return $cart;
}

public function setOrderStatus(
OrderShopInterface $orderShop,
string $alias,
bool $forceByAdmin = false
): OrderShopInterface {
$orderStatus = $this->orderStatusStore->getOneByAlias($alias);

if ($orderStatus) {
if ($orderShop->getOrderStatus() === null
|| $orderShop->getOrderStatus()->getNextStatusAllowed()->contains($orderStatus)) {
$this->applyChangeOrderStatus($orderShop, $orderStatus, $forceByAdmin);
}
} else {
throw new \ErrorException('La statut demandé n\'existe pas.');
}

return $orderShop;
}

public function applyChangeOrderStatus(
OrderShopInterface $orderShop,
OrderStatusInterface $orderStatus,
bool $forceByAdmin = false
): void {
$this->eventDispatcher->dispatch(
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
OrderShopChangeStatusEvent::PRE_CHANGE_STATUS
);

$orderShop->setOrderStatusProtected($orderStatus);

$orderStatusHistoryFactory = new OrderStatusHistoryFactory();
$orderStatusHistory = $orderStatusHistoryFactory->create($orderShop, $orderStatus);

$orderShop->addOrderStatusHistory($orderStatusHistory);

$this->eventDispatcher->dispatch(
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin),
OrderShopChangeStatusEvent::POST_CHANGE_STATUS
);
}

public function addOrderProduct(
OrderShopInterface $orderShop,
OrderProductInterface $orderProductAdd,
bool $persist = true
): bool {
$return = false;

if ($this->orderShopSolver->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) {
if ($orderProductAdd->getQuantityOrder() > 0) {
$updated = false;
$this->orderProductBuilder->init($orderProductAdd);
$productFamily = $this->productFamilyStore->getOneBySlug(
$orderProductAdd->getProduct()->getProductFamily()->getSlug()
);

if ($productFamily) {
$reductionCatalog = $productFamily->getReductionCatalog();

if ($reductionCatalog) {
$orderProductReductionCatalogFactory = new OrderProductReductionCatalogFactory();
$orderProductReductionCatalog = $orderProductReductionCatalogFactory->create(
$reductionCatalog->getTitle(),
$reductionCatalog->getValue(),
$reductionCatalog->getUnit(),
$reductionCatalog->getBehaviorTaxRate()
);

$orderProductAdd->setOrderProductReductionCatalog($orderProductReductionCatalog);
}
}

foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($orderProduct->getProduct()->getId() == $orderProductAdd->getProduct()->getId()
&& $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery()
&& (string)$this->priceSolver->getPrice($orderProduct)
== (string)$this->priceSolver->getPrice($orderProductAdd)
&& $this->orderProductReductionCatalogSolver->compare(
$orderProduct->getOrderProductReductionCatalog(),
$orderProductAdd->getOrderProductReductionCatalog()
)) {
$orderProduct->setQuantityOrder(
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
);

if ($persist) {
$this->entityManager->update($orderProduct);
}

$updated = true;
$return = true;

break;
}
}

if (!$updated) {
$orderShop->addOrderProduct($orderProductAdd);

if ($persist) {
if (isset($orderProductReductionCatalog)) {
$this->entityManager->create($orderProductReductionCatalog);
}
//TODO est-ce un update ou un create ???
$this->entityManager->persist($orderProductAdd);
$this->entityManager->update($orderShop);
}

$return = true;
}

if ($persist) {
$this->entityManager->flush();
}

// @TODO : dispatch event cart change
//$this->eventCartChange($orderShop);
}
} else {
// @TODO : retourner le message d'erreur et faire le addFlash dans le contrôleur
/*$availableQuantity = $orderProductAdd->getProduct()->getAvailableQuantityInherited();
$textError = "Le produit <strong>" . $orderProductAdd->getTitleOrderShop(
) . "</strong> n'est pas disponible";
if ($availableQuantity !== false && $availableQuantity > 0) {
$unit = '';
if ($orderProductAdd->getProduct()->getProductFamily()->getBehaviorCountStock(
) == ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE) {
$unit = $orderProductAdd->getProduct()->getUnitInherited()->getUnitReference()->getUnit();
}
$textError .= ' dans cette quantité ';

$user = $this->security->getUser();
if ($user && $user->hasRole('ROLE_USER')) {
$textError .= '<br />' . $availableQuantity . $unit . ' disponible(s) dont ' . $this->getQuantityOrderByProduct(
$orderShop,
$orderProductAdd->getProduct()
) . $unit . ' déjà dans votre panier.';
}
}
$this->utils->addFlash('error', $textError);*/
}

return $return;
}

public function merge(
OrderShopInterface $orderShop1,
OrderShopInterface $orderShop2,
$persist = true
): OrderShopInterface {
//TODO essayer de comprendre prk on doit faire un refresh ici ???
$this->entityManager->refresh($orderShop1);
$this->entityManager->refresh($orderShop2);
if ($orderShop1 && $orderShop2) {
foreach ($orderShop2->getOrderProducts() as $orderProduct) {
$orderProductAlreadyInCart = $this->orderShopSolver->hasOrderProductAlreadyInCart($orderShop1, $orderProduct);

if ($orderProductAlreadyInCart) {
if ($orderProduct->getQuantityOrder() > $orderProductAlreadyInCart->getQuantityOrder()) {
$orderShop1->removeOrderProduct($orderProductAlreadyInCart);
$this->addOrderProduct($orderShop1, $orderProduct);
}
} else {
$this->addOrderProduct($orderShop1, $orderProduct);
}

if ($persist) {
$this->entityManager->delete($orderProduct);
}
}

if ($persist) {
$this->entityManager->delete($orderShop2);
$this->entityManager->update($orderShop1);
$this->entityManager->flush();
}

return $orderShop1;
}
}

public function addPayment(OrderShopInterface $orderShop, string $meanPayment, float $amount): OrderShopInterface
{
$orderPaymentFactory = new OrderPaymentFactory();
$orderPayment = $orderPaymentFactory->create($orderShop, $meanPayment, $amount);

$orderShop->addOrderPayment($orderPayment);

if($meanPayment == OrderPaymentModel::MEAN_PAYMENT_CREDIT) {
$this->creditHistoryBuilder->create(CreditHistoryModel::TYPE_DEBIT, $this->merchantResolver->getUserMerchant(), [
'orderPayment' => $orderPayment
]);
}

if ($this->orderShopResolver->isPaid($orderShop)) {
$nextStatus = OrderStatusModel::ALIAS_PAID;
} else {
$nextStatus = OrderStatusModel::ALIAS_PARTIAL_PAYMENT;
}

if ($orderShop->getOrderStatus()->getAlias() != $nextStatus) {
$this->changeOrderStatus($orderShop, $nextStatus);
}

$this->entityManager->create($orderPayment);
$this->entityManager->update($orderShop);
$this->entityManager->flush();

return $orderShop;
}


public function initStatsInfo(OrderShopInterface $orderShop, $flush = true)
{
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
$orderShop->setStatTotalOrderProductsWithReductions(
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
);
$orderShop->setStatTotalOrderProductsWithTaxAndReductions(
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
);
$orderShop->setStatMarginOrderProductsWithReductions(
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
);
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
$orderShop->setStatDeliveryPriceWithTaxAndReduction(
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
);

$this->entityManager->persist($orderShop);
if ($flush) {
$this->entityManager->flush();
}
}

//initCycleNumber
public function initDistribution(OrderShopInterface $orderShop): void
{
$distribution = $this->distributionBuilder->guessDistributionByDeliveryDate(
$orderShop->getDeliveryDate(),
$orderShop->getSection()
);
$orderShop->setDistribution($distribution);
}


public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface
{
$documentFactory = new DocumentFactory();

$document = $documentFactory->create($orderShop->getSection()->getMerchant(), DocumentModel::TYPE_INVOICE);

$this->documentBuilder->initFromOrderShop($document, $orderShop);
return $document;
}

public function addReductionCart(
OrderShopInterface $orderShop,
ReductionCartInterface $reductionCart
): ?OrderReductionCartInterface {
$orderReductionCartFactory = new OrderReductionCartFactory();
$orderReductionCart = $orderReductionCartFactory->create($orderShop, $reductionCart);

$orderShop->addOrderReductionCart($orderReductionCart);

if ($this->orderShopResolver->isPositiveAmount($orderShop)
&& $this->orderShopResolver->isPositiveAmountRemainingToBePaid($orderShop)) {
$this->entityManager->create($orderReductionCart);
$this->entityManager->flush();

return $orderReductionCart;
} else {
//TODO vérifier ce case ! Avec le null en valeur de retour
$orderShop->removeOrderReductionCart($orderReductionCart);
return null;
}
}

// createOrderReductionCredit
public function addReductionCredit(
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
): ?OrderReductionCreditInterface {
$orderReductionCreditFactory = new OrderReductionCreditFactory();
$orderReductionCredit = $orderReductionCreditFactory->create($orderShop, $reductionCredit);

$orderShop->addOrderReductionCredit($orderReductionCredit);

if ($this->isOrderShopPositiveAmount($orderShop)
&& $this->isOrderShopPositiveAmountRemainingToBePaid($orderShop)) {
$this->entityManager->create($orderReductionCredit);
$this->entityManager->flush();

return $orderReductionCredit;
} else {
$orderShop->removeOrderReductionCredit($orderReductionCredit);

return null;
}
}

public function deductAvailabilityProduct(OrderShopInterface $orderShop): void
{
foreach ($orderShop->getOrderProducts() as $orderProduct) {
$this->applyDeductAvailabilityProduct($orderShop, $orderProduct);
}
}

public function applyDeductAvailabilityProduct(
OrderShopInterface $orderShop,
OrderProductInterface $orderProduct
): void {
switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) {
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE :

//Disponibilité par unité de référence
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder(
) * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()));

$productFamily = $orderProduct->getProduct()->getProductFamily();
$productFamily->setAvailableQuantity($newAvailability);
$productFamily->setUpdatedBy($orderShop->getUser());

$this->entityManager->update($productFamily);

break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :

$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();

$productFamily = $orderProduct->getProduct()->getProductFamily();
$productFamily->setAvailableQuantity($newAvailability);
$productFamily->setUpdatedBy($orderShop->getUser());

$this->entityManager->update($productFamily);

break;
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
$oldAvailability = $this->productSolver->getAvailableQuantityInherited($orderProduct->getProduct());
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder();

$product = $orderProduct->getProduct();
$product->setAvailableQuantity($newAvailability);
$product->setUpdatedBy($orderShop->getUser());

$this->entityManager->update($product);

break;
}
$this->entityManager->flush();
}


public function updatePriceByProductFamily(ProductFamilyInterface $productFamily)
{
// @TODO : faire la vérification isOpenSale depuis la méthode appelante
if (!$this->openingResolver->isOpenSale(
$productFamily->getSection(),
null,
OpeningResolver::OPENING_CONTEXT_BACKEND
)) {
$countOrderProductUpdated = 0;

foreach ($productFamily->getProducts() as $product) {
$orderProducts = $this->orderProductStore->getInCartsByProduct($product);

foreach ($orderProducts as $orderProduct) {
$quantityOrder = $orderProduct->getQuantityOrder();
$orderShop = $orderProduct->getOrderShop();
$orderShop->removeOrderProduct($orderProduct);
$this->entityManager->delete($orderProduct);
$this->entityManager->flush();
$this->entityManager->refresh($orderShop);

$orderProductFactory = new OrderProductFactory();
$addOrderProduct = $orderProductFactory->create($product, $quantityOrder);
$this->addOrderProduct($orderShop, $addOrderProduct);

$countOrderProductUpdated++;
}
}
if ($countOrderProductUpdated) {
// @TODO : faire le add flash dans le controller
/*$this->utils->addFlash(
'success',
'success.OrderShop.orderProductUpdated',
array(),
array('%count%' => $countOrderProductUpdated)
);*/
$this->entityManager->flush();
}

return $countOrderProductUpdated;
}
}


public function setStatsInfo(OrderShopInterface $orderShop, $flush = true)
{
$orderShop->setStatTotal($this->priceSolver->getTotal($orderShop));
$orderShop->setStatTotalWithTax($this->priceSolver->getTotalWithTax($orderShop));
$orderShop->setStatTotalOrderProductsWithReductions(
$this->priceSolver->getTotalOrderProductsWithReductions($orderShop)
);
$orderShop->setStatTotalOrderProductsWithTaxAndReductions(
$this->priceSolver->getTotalOrderProductsWithTaxAndReductions($orderShop)
);
$orderShop->setStatMarginOrderProductsWithReductions(
$this->priceSolver->getMarginOrderProductsWithReductions($orderShop)
);
$orderShop->setStatDeliveryPriceWithReduction($this->priceSolver->getDeliveryPriceWithReduction($orderShop));
$orderShop->setStatDeliveryPriceWithTaxAndReduction(
$this->priceSolver->getDeliveryPriceWithTaxAndReduction($orderShop)
);

$this->entityManager->update($orderShop);
if ($flush) {
$this->entityManager->flush();
}
}


public function setHasReach(int $reachStep, OrderShopInterface $orderShop)
{
if ($orderShop->getHasReach() === null || $orderShop->getHasReach() < $reachStep) {
$orderShop->setHasReach($reachStep);
$this->entityManager->persist($orderShop);
$this->entityManager->flush($orderShop);
}
}

public function initComplementaryOrderShop(OrderShopInterface $orderShop, OrderShopInterface $mainOrderShop): void
{
$orderShop->setMainOrderShop($mainOrderShop);
$orderShop->setDeliveryPrice(0);

if ($mainOrderShop->getDeliveryAddress()) {
$this->initDeliveryAddress($orderShop, $mainOrderShop->getDeliveryAddress());
}

$orderShop->setInvoiceAddress($mainOrderShop->getInvoiceAddress());
}

// setDeliveryAddress
public function initDeliveryAddress(OrderShopInterface $orderShop, AddressInterface $address = null): void
{
$orderShop->setDeliveryAddress($address);
$orderShop->setDeliveryInfos($address ? $address->getDeliveryInfos() : null);
}

// resetOrderShopInfos
public function reset(OrderShopInterface $orderShop)
{
$this->initDeliveryAddress($orderShop, null);
$orderShop->setMainOrderShop(null);
$orderShop->setDeliveryPrice(null);
$orderShop->setInvoiceAddress(null);
$orderShop->setDeclineComplementaryOrderShop(false);
}

public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2)
{
$productsSalesStatistic = new ProductsSalesStatistic(
$this->entityManager,
$entity,
$nbWeek,
$this->productSolver
);

$productsSalesStatistic->init($section, $this->distributionBuilder, $this->openingResolver);
$productsSalesStatistic->populateProperties($this->orderShopStore);

return $productsSalesStatistic->getAsArray();
}


}

+ 8
- 0
Builder/Product/ProductFamilyBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Product;

class ProductFamilyBuilder
{

}

+ 49
- 0
Builder/Product/ProductFamilySectionPropertyBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Product;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;

class ProductFamilySectionPropertyBuilder
{
protected EntityManagerInterface $entityManager;
protected ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory;
protected ProductFamilySectionPropertyStore $productFamilySectionPropertyStore;

public function __construct(
EntityManagerInterface $entityManager,
ProductFamilySectionPropertyFactory $productFamilySectionPropertyFactory,
ProductFamilySectionPropertyStore $productFamilySectionPropertyStore
) {
$this->entityManager = $entityManager;
$this->productFamilySectionPropertyFactory = $productFamilySectionPropertyFactory;
$this->productFamilySectionPropertyStore = $productFamilySectionPropertyStore;
}

public function enable(ProductFamilyInterface $productFamily, SectionInterface $section, bool $flush = true): void
{
$productFamilySectionProperty = $this->productFamilySectionPropertyStore
->setSection($section)
->getOneByProductFamily($productFamily);

if ($productFamilySectionProperty) {
if (!$productFamilySectionProperty->getStatus()) {
$productFamilySectionProperty->setStatus(1);
$this->entityManager->update($productFamilySectionProperty);
}
} else {
$productFamilySectionProperty = $this->productFamilySectionPropertyFactory->create($section, $productFamily);
$productFamilySectionProperty->setStatus(1);
$this->entityManager->create($productFamilySectionProperty);
}

if($flush) {
$this->entityManager->flush();
}
}

}

+ 82
- 0
Builder/Reduction/ReductionCreditBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Reduction;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\Reduction\ReductionCreditFactory;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\CaracoleBundle\Solver\User\UserSolver;
use Lc\CaracoleBundle\Notification\MailMailjetNotification;

class ReductionCreditBuilder
{
protected EntityManagerInterface $entityManager;
protected OrderProductStore $orderProductStore;
protected ReductionCreditFactory $reductionCreditFactory;
protected PriceSolver $priceSolver;
protected MailMailjetNotification $mailMailjetNotification;
protected UserSolver $userSolver;
protected SectionStore $sectionStore;

public function __construct(
EntityManagerInterface $entityManager,
OrderProductStore $orderProductStore,
ReductionCreditFactory $reductionCreditFactory,
PriceSolver $priceSolver,
MailMailjetNotification $mailMailjetNotification,
UserSolver $userSolver,
SectionStore $sectionStore
) {
$this->entityManager = $entityManager;
$this->orderProductStore = $orderProductStore;
$this->reductionCreditFactory = $reductionCreditFactory;
$this->priceSolver = $priceSolver;
$this->mailMailjetNotification = $mailMailjetNotification;
$this->userSolver = $userSolver;
$this->sectionStore = $sectionStore;
}

// generateReductionGiftFormOrderShop
public function createReductionGiftFormOrderShop(OrderShopInterface $orderShop)
{
$user = $orderShop->getUser();
$orderProductsGiftVouchers = $this->orderProductStore->getGiftVouchersByOrder($orderShop);

$sectionMarket = $this->sectionStore
->setMerchant($orderShop->getSection()->getMerchant())
->getOneMarket();

foreach ($orderProductsGiftVouchers as $orderProductsGiftVoucher) {
$i = 1;

// création de la reductionCredit
while ($i <= $orderProductsGiftVoucher->getQuantityOrder()) {
$reductionGift = $this->reductionCreditFactory->create($sectionMarket, ReductionCreditModel::TYPE_GIFT);
$reductionGift->setTitle($orderProductsGiftVoucher->getTitle());
$reductionGift->setOwner($user);
$reductionGift->setCreatedBy($user);
$reductionGift->setUpdatedBy($user);
$reductionGift->setValue($this->priceSolver->getPriceWithTax($orderProductsGiftVoucher->getProduct()));
$reductionGift->setBehaviorTaxRate(TaxRateModel::BEHAVIOR_TAX_RATE_INCLUDED);
$this->entityManager->persist($reductionGift);

$i++;
}
}
$this->entityManager->flush();

if (count($orderProductsGiftVouchers) > 0) {
$this->mailMailjetNotification->send([
MailMailjetNotification::SUBJECT => 'Comment offrir votre bon cadeau ?',
MailMailjetNotification::TO_EMAIL => $user->getEmail(),
MailMailjetNotification::TO_NAME => $this->userSolver->getName($user),
MailMailjetNotification::CONTENT_TEMPLATE => 'mail/how-to-offer-gift-voucher'
]);
}
}
}

+ 132
- 0
Builder/Setting/SettingBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Setting;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Definition\SectionSettingDefinition;
use Lc\CaracoleBundle\Factory\Setting\MerchantSettingFactory;
use Lc\CaracoleBundle\Factory\Setting\SectionSettingFactory;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\SovBundle\Definition\SiteSettingDefinition;
use Lc\SovBundle\Factory\Setting\SiteSettingFactory;
use Lc\SovBundle\Repository\Site\SiteStore;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Lc\SovBundle\Builder\Setting\SettingBuilder as SovSettingBuilder;

class SettingBuilder extends SovSettingBuilder
{
protected MerchantStore $merchantStore;
protected MerchantSettingDefinition $merchantSettingDefinition;
protected MerchantSettingFactory $merchantSettingFactory;
protected SectionSettingDefinition $sectionSettingDefinition;
protected SectionSettingFactory $sectionSettingFactory;

public function __construct(
EntityManagerInterface $entityManager,
SettingSolver $settingSolver,
SiteStore $siteStore,
SiteSettingDefinition $siteSettingDefinition,
SiteSettingFactory $siteSettingFactory,
MerchantStore $merchantStore,
MerchantSettingDefinition $merchantSettingDefinition,
MerchantSettingFactory $merchantSettingFactory,
SectionSettingDefinition $sectionSettingDefinition,
SectionSettingFactory $sectionSettingFactory
) {
parent::__construct($entityManager, $settingSolver, $siteStore, $siteSettingDefinition, $siteSettingFactory);

$this->merchantStore = $merchantStore;
$this->merchantSettingDefinition = $merchantSettingDefinition;
$this->merchantSettingFactory = $merchantSettingFactory;
$this->sectionSettingDefinition = $sectionSettingDefinition;
$this->sectionSettingFactory = $sectionSettingFactory;
}

public function initMerchantSettings()
{
$merchants = $this->merchantStore->get();

$this->initSettingsGeneric(
$this->merchantSettingDefinition->getSettings(),
$merchants,
$this->merchantSettingFactory
);
}

public function initSectionSettings()
{
$merchants = $this->merchantStore->get();

foreach($merchants as $merchant) {
$this->initSettingsGeneric(
$this->sectionSettingDefinition->getSettings(),
$merchant->getSections(),
$this->sectionSettingFactory
);
}
}

protected function initSettingsGeneric($settings, $entities, $factory)
{
if($entities) {
foreach ($entities as $entity) {

$this->entityManager->refresh($entity);

foreach ($settings as $category => $settingList) {
foreach ($settingList as $settingName => $setting) {

$entitySetting = $this->settingSolver->getSetting($entity, $settingName);

if (!$entitySetting) {

// gestion du cas des SectionSetting spécifiques à une section
$createEntitySetting = true;
if ($entity instanceof SectionInterface && isset($setting['section']) && $setting['section'] != $entity) {
$createEntitySetting = false;
}

if ($createEntitySetting) {
$text = null;
$date = null;
$file = null;

$valueDefault = isset($setting['default']) ? $this->settingSolver->getDefaultValue($entity, $setting['default']) : null;

if ($setting['field'] == 'text') {
$text = $valueDefault;
} elseif ($setting['field'] == 'date') {
$date = $valueDefault;
} elseif ($setting['field'] == 'file') {
$file = $valueDefault;
}

$entitySetting = $factory->create($entity, $setting['name'], $text, $date, $file);

$this->entityManager->create($entitySetting);
}
} else {
if ($this->settingSolver->getValue($entitySetting) === null
&& isset($setting['default'])
&& $setting['default'] !== null) {

$valueDefault = $this->settingSolver->getDefaultValue($entity, $setting['default']);

if($valueDefault) {
$methodSetValue = 'set' . ucfirst($setting['field']);
$entitySetting->$methodSetValue($valueDefault);
$this->entityManager->update($entitySetting);
}
}
}
}
}
}

$this->entityManager->flush();
}
}

}

+ 20
- 0
Builder/Ticket/TicketBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\Ticket;

use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Builder\Ticket\TicketBuilder as SovTicketBuilder;

class TicketBuilder extends SovTicketBuilder
{

public function init(TicketInterface $ticket, array $params = []): void
{
parent::init($ticket, $params);

$ticket->setSection($params['section']);
if(isset($data['orderShop'])) {
$ticket->setOrderShop($data['orderShop']);
}
}
}

+ 29
- 0
Builder/User/UserBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\User;

use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Builder\User\UserBuilder as SovUserBuilder;

class UserBuilder extends SovUserBuilder
{

// linkUserToPointSale
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale):bool
{
if (!$this->userSolver->isLinkedToPointSale($user, $pointSale)) {
$userPointSaleFactory = new UserPointSaleFactory();
$userPointSale = $userPointSaleFactory->create($user, $pointSale);

$this->entityManager->create($userPointSale);
$this->entityManager->flush();

return true;
}

return false;
}
}


+ 105
- 0
Builder/User/UserMerchantBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\User;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\User\UserMerchantStore;
use Lc\SovBundle\Model\User\UserInterface;

class UserMerchantBuilder
{
protected EntityManagerInterface $entityManager;
protected UserMerchantStore $userMerchantStore;

public function __construct(
EntityManagerInterface $entityManager,
UserMerchantStore $userMerchantStore
) {
$this->entityManager = $entityManager;
$this->userMerchantStore = $userMerchantStore;
}

public function createIfNotExist(UserInterface $user, MerchantInterface $merchant): UserMerchantInterface
{
$userMerchant = $this->userMerchantStore
->setMerchant($merchant)
->getOneByUser($user);

if (!$userMerchant) {
$userMerchantFactory = new UserMerchantFactory();
$userMerchant = $userMerchantFactory->create($merchant, $user);

$this->entityManager->create($userMerchant);
$this->entityManager->flush();
}

return $userMerchant;
}

public function init(
UserInterface $user,
MerchantInterface $merchant,
bool $active = true,
bool $creditActive = false,
float $credit = null,
bool $persist = true
): UserMerchantInterface {
$userMerchant = $this->createIfNotExist($user, $merchant);

$userMerchant->setActive($active);
$userMerchant->setCreditActive($creditActive);
$userMerchant->setCredit($credit);

if ($persist) {
//TODO create ou update ???
$this->entityManager->persist($userMerchant);
$this->entityManager->flush();
}

return $userMerchant;
}

public function activeCredit(UserMerchantInterface $userMerchant): UserMerchantInterface
{
return $this->updateCreditActive($userMerchant, true);
}

public function unactiveCredit(UserMerchantInterface $userMerchant): UserMerchantInterface
{
return $this->updateCreditActive($userMerchant, false);
}

public function updateCredit(
UserMerchantInterface $userMerchant,
CreditHistoryInterface $creditHistory,
float $amount
): UserMerchantInterface {
$userMerchant->setCredit($amount);

$this->entityManager->update($creditHistory);
$this->entityManager->update($userMerchant);
$this->entityManager->flush();

return $userMerchant;
}

public function updateCreditActive(
UserMerchantInterface $userMerchant,
$creditActive = true
): UserMerchantInterface {

$userMerchant->setCreditActive($creditActive);

//TODO create ou update ???
$this->entityManager->persist($userMerchant);
$this->entityManager->flush();

return $userMerchant;
}

}


+ 77
- 0
Builder/User/VisitorBuilder.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Builder\User;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Factory\User\VisitorFactory;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
use Lc\SovBundle\Component\CookieComponent;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Cookie;

class VisitorBuilder
{
protected CookieComponent $cookieComponent;
protected ParameterBagInterface $parameterBag;
protected EntityManagerInterface $entityManager;

public function __construct(
EntityManagerInterface $entityManager,
CookieComponent $cookieComponent,
ParameterBagInterface $parameterBag
) {
$this->entityManager = $entityManager;
$this->cookieComponent = $cookieComponent;
$this->parameterBag = $parameterBag;
}

// addVisitor
public function create(string $cookie, string $ip)
{
$visitorFactory = new VisitorFactory();
$visitor = $visitorFactory->create($cookie, $ip);

$this->entityManager->create($visitor);
$this->entityManager->flush();
}

public function update(VisitorInterface $visitor)
{
$totalVisit = $visitor->getTotalVisit() + 1;

$visitor->setTotalVisit($totalVisit);
$visitor->setLastAccess(new \DateTime());

$this->entityManager->update($visitor);
$this->entityManager->flush();
}

// setCookieVisitor
public function setCookie($response, $cookie): void
{
$response->headers->setCookie(
Cookie::create(
$this->parameterBag->get('app.cookie_name_visitor'),
$this->cookieComponent->cryptCookie($cookie),
new \DateTime('+2 months'),
'/',
$this->cookieComponent->getCookieDomain()
)
);
}

// updateVisitorCookie
public function updateCookie($response): void
{
$response->headers->setCookie(
Cookie::create(
$this->parameterBag->get('app.cookie_name_visitor'),
$this->cookieComponent->cryptCookie($this->getVisitorCurrent()->getCookie()),
new \DateTime('+2 months'),
'/',
$this->cookieComponent->getCookieDomain()
)
);
}

}

+ 34
- 0
Command/MerchantSettingInitCommand.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Command;

use Lc\SovBundle\Builder\Setting\SettingBuilder;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class MerchantSettingInitCommand extends Command
{
protected static $defaultName = 'setting:merchant:init';
protected static $defaultDescription = 'Initialise les MerchantSetting.';

protected SettingBuilder $settingBuilder;

public function __construct(string $name = null, SettingBuilder $settingBuilder)
{
parent::__construct($name);
$this->settingBuilder = $settingBuilder;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
$this->settingBuilder->initMerchantSettings();
$this->io->success('Les MerchantSetting ont bien été initialisées.');
return Command::SUCCESS;
}
}

+ 34
- 0
Command/SectionSettingInitCommand.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Command;

use Lc\SovBundle\Builder\Setting\SettingBuilder;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class SectionSettingInitCommand extends Command
{
protected static $defaultName = 'setting:section:init';
protected static $defaultDescription = 'Initialise les SectionSetting.';

protected SettingBuilder $settingBuilder;

public function __construct(string $name = null, SettingBuilder $settingBuilder)
{
parent::__construct($name);
$this->settingBuilder = $settingBuilder;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
$this->settingBuilder->initSectionSettings();
$this->io->success('Les SectionSetting ont bien été initialisées.');
return Command::SUCCESS;
}
}

+ 59
- 0
Container/Address/AddressContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Address;

use Lc\CaracoleBundle\Builder\Address\AddressBuilder;
use Lc\CaracoleBundle\Factory\Address\AddressFactory;
use Lc\CaracoleBundle\Repository\Address\AddressRepositoryQuery;
use Lc\CaracoleBundle\Repository\Address\AddressStore;
use Lc\CaracoleBundle\Solver\Address\AddressSolver;

class AddressContainer
{
protected AddressFactory $factory;
protected AddressSolver $solver;
protected AddressRepositoryQuery $repositoryQuery;
protected AddressStore $store;
protected AddressBuilder $builder;

public function __construct(
AddressFactory $factory,
AddressSolver $solver,
AddressRepositoryQuery $repositoryQuery,
AddressStore $store,
AddressBuilder $builder
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
}

public function getFactory(): AddressFactory
{
return $this->factory;
}

public function getSolver(): AddressSolver
{
return $this->solver;
}

public function getRepositoryQuery(): AddressRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getBuilder(): AddressBuilder
{
return $this->builder;
}
}

+ 41
- 0
Container/Config/TaxRateContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Config;

use Lc\CaracoleBundle\Factory\Config\TaxRateFactory;
use Lc\CaracoleBundle\Repository\Config\TaxRateRepositoryQuery;
use Lc\CaracoleBundle\Repository\Config\TaxRateStore;

class TaxRateContainer
{
protected TaxRateFactory $factory;
protected TaxRateRepositoryQuery $repositoryQuery;
protected TaxRateStore $store;

public function __construct(
TaxRateFactory $factory,
TaxRateRepositoryQuery $repositoryQuery,
TaxRateStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): TaxRateFactory
{
return $this->factory;
}

public function getRepositoryQuery(): TaxRateRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}
}

+ 39
- 0
Container/Config/UnitContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Config;

use Lc\CaracoleBundle\Factory\Config\UnitFactory;
use Lc\CaracoleBundle\Repository\Config\UnitRepositoryQuery;
use Lc\CaracoleBundle\Repository\Config\UnitStore;

class UnitContainer
{
protected UnitFactory $factory;
protected UnitRepositoryQuery $repositoryQuery;
protected UnitStore $store;

public function __construct(
UnitFactory $factory,
UnitRepositoryQuery $repositoryQuery,
UnitStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): UnitFactory
{
return $this->factory;
}

public function getRepositoryQuery(): UnitRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): UnitStore
{
return $this->store;
}
}

+ 68
- 0
Container/Credit/CreditHistoryContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Credit;

use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder;
use Lc\CaracoleBundle\Definition\Field\Credit\CreditHistoryFieldDefinition;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryRepositoryQuery;
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryStore;
use Lc\CaracoleBundle\Solver\Credit\CreditHistorySolver;

class CreditHistoryContainer
{
protected CreditHistoryFactory $factory;
protected CreditHistoryRepositoryQuery $repositoryQuery;
protected CreditHistoryStore $store;
protected CreditHistoryBuilder $builder;
protected CreditHistorySolver $solver;
protected CreditHistoryFieldDefinition $fieldDefinition;

public function __construct(
CreditHistoryFactory $factory,
CreditHistoryRepositoryQuery $repositoryQuery,
CreditHistorySolver $solver,
CreditHistoryStore $store,
CreditHistoryBuilder $builder,
CreditHistoryFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->solver = $solver;
$this->store = $store;
$this->builder = $builder;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): CreditHistoryFactory
{
return $this->factory;
}

public function getRepositoryQuery(): CreditHistoryRepositoryQuery
{
return $this->repositoryQuery;
}

public function getSolver(): CreditHistorySolver
{
return $this->solver;
}

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

return $this->store;
}

public function getBuilder(): CreditHistoryBuilder
{
return $this->builder;
}

public function getFieldDefinition(): CreditHistoryFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 59
- 0
Container/Distribution/DistributionContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Distribution;


use Lc\CaracoleBundle\Builder\Distribution\DistributionBuilder;
use Lc\CaracoleBundle\Factory\Distribution\DistributionFactory;
use Lc\CaracoleBundle\Repository\Distribution\DistributionRepositoryQuery;
use Lc\CaracoleBundle\Repository\Distribution\DistributionStore;
use Lc\CaracoleBundle\Solver\Distribution\DistributionSolver;

class DistributionContainer
{
protected DistributionFactory $factory;
protected DistributionRepositoryQuery $repositoryQuery;
protected DistributionStore $store;
protected DistributionBuilder $builder;
protected DistributionSolver $solver;

public function __construct(
DistributionFactory $factory,
DistributionRepositoryQuery $repositoryQuery,
DistributionStore $store,
DistributionBuilder $builder,
DistributionSolver $solver
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->solver = $solver;
$this->builder = $builder;
}

public function getFactory(): DistributionFactory
{
return $this->factory;
}

public function getRepositoryQuery(): DistributionRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): DistributionStore
{
return $this->store;
}

public function getSolver(): DistributionSolver
{
return $this->solver;
}

public function getBuilder(): DistributionBuilder
{
return $this->builder;
}

}

+ 41
- 0
Container/File/DocumentContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\File;

use Lc\CaracoleBundle\Factory\File\DocumentFactory;
use Lc\CaracoleBundle\Repository\File\DocumentRepositoryQuery;
use Lc\CaracoleBundle\Repository\File\DocumentStore;

class DocumentContainer
{
protected DocumentFactory $factory;
protected DocumentRepositoryQuery $repositoryQuery;
protected DocumentStore $store;

public function __construct(
DocumentFactory $factory,
DocumentRepositoryQuery $repositoryQuery,
DocumentStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): DocumentFactory
{
return $this->factory;
}

public function getRepositoryQuery(): DocumentRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}
}

+ 67
- 0
Container/Merchant/MerchantContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Merchant;

use Lc\CaracoleBundle\Builder\Merchant\MerchantBuilder;
use Lc\CaracoleBundle\Factory\Merchant\MerchantFactory;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Solver\Merchant\MerchantSolver;
use Lc\SovBundle\Solver\Setting\SettingSolver;

class MerchantContainer
{
protected MerchantFactory $factory;
protected MerchantSolver $solver;
protected MerchantBuilder $builder;
protected MerchantResolver $resolver;
protected MerchantRepositoryQuery $repositoryQuery;
protected MerchantStore $store;

public function __construct(
MerchantFactory $factory,
MerchantSolver $solver,
MerchantBuilder $builder,
MerchantResolver $resolver,
MerchantRepositoryQuery $repositoryQuery,
MerchantStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->builder = $builder;
$this->resolver = $resolver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): MerchantFactory
{
return $this->factory;
}

public function getSolver(): MerchantSolver
{
return $this->solver;
}

public function getResolver(): MerchantResolver
{
return $this->resolver;
}

public function getRepositoryQuery(): MerchantRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): MerchantStore
{
return $this->store;
}

public function getBuilder(): MerchantBuilder
{
return $this->builder;
}
}

+ 39
- 0
Container/Order/OrderPaymentContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory;
use Lc\CaracoleBundle\Repository\Order\OrderPaymentRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderPaymentStore;

class OrderPaymentContainer
{
protected OrderPaymentFactory $factory;
protected OrderPaymentRepositoryQuery $repositoryQuery;
protected OrderPaymentStore $store;

public function __construct(
OrderPaymentFactory $factory,
OrderPaymentRepositoryQuery $repositoryQuery,
OrderPaymentStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderPaymentFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderPaymentRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderPaymentStore
{
return $this->store;
}
}

+ 57
- 0
Container/Order/OrderProductContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Builder\Order\OrderProductBuilder;
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
use Lc\CaracoleBundle\Repository\Order\OrderProductRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
use Lc\CaracoleBundle\Solver\Order\OrderProductSolver;

class OrderProductContainer
{
protected OrderProductFactory $factory;
protected OrderProductSolver $solver;
protected OrderProductBuilder $builder;
protected OrderProductRepositoryQuery $repositoryQuery;
protected OrderProductStore $store;

public function __construct(
OrderProductFactory $factory,
OrderProductSolver $solver,
OrderProductBuilder $builder,
OrderProductRepositoryQuery $repositoryQuery,
OrderProductStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->builder = $builder;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderProductFactory
{
return $this->factory;
}

public function getSolver(): OrderProductSolver
{
return $this->solver;
}

public function getBuilder(): OrderProductBuilder
{
return $this->builder;
}

public function getRepositoryQuery(): OrderProductRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderProductStore
{
return $this->store;
}
}

+ 49
- 0
Container/Order/OrderProductReductionCatalogContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory;
use Lc\CaracoleBundle\Repository\Order\OrderProductReductionCatalogRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderProductReductionCatalogStore;
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver;

class OrderProductReductionCatalogContainer
{
protected OrderProductReductionCatalogFactory $factory;
protected OrderProductReductionCatalogSolver $solver;
protected OrderProductReductionCatalogRepositoryQuery $repositoryQuery;
protected OrderProductReductionCatalogStore $store;

public function __construct(
OrderProductReductionCatalogFactory $factory,
OrderProductReductionCatalogSolver $solver,
OrderProductReductionCatalogRepositoryQuery $repositoryQuery,
OrderProductReductionCatalogStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderProductReductionCatalogFactory
{
return $this->factory;
}

public function getSolver(): OrderProductReductionCatalogSolver
{
return $this->solver;
}

public function getRepositoryQuery(): OrderProductReductionCatalogRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderProductReductionCatalogStore
{
return $this->store;
}

}

+ 40
- 0
Container/Order/OrderProductRefundContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderProductRefundFactory;
use Lc\CaracoleBundle\Repository\Order\OrderProductRefundRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderProductRefundStore;

class OrderProductRefundContainer
{
protected OrderProductRefundFactory $factory;
protected OrderProductRefundRepositoryQuery $repositoryQuery;
protected OrderProductRefundStore $store;

public function __construct(
OrderProductRefundFactory $factory,
OrderProductRefundRepositoryQuery $repositoryQuery,
OrderProductRefundStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderProductRefundFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderProductRefundRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderProductRefundStore
{
return $this->store;
}

}

+ 40
- 0
Container/Order/OrderReductionCartContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory;
use Lc\CaracoleBundle\Repository\Order\OrderReductionCartRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderReductionCartStore;

class OrderReductionCartContainer
{
protected OrderReductionCartFactory $factory;
protected OrderReductionCartRepositoryQuery $repositoryQuery;
protected OrderReductionCartStore $store;

public function __construct(
OrderReductionCartFactory $factory,
OrderReductionCartRepositoryQuery $repositoryQuery,
OrderReductionCartStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderReductionCartFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderReductionCartRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderReductionCartStore
{
return $this->store;
}

}

+ 40
- 0
Container/Order/OrderReductionCreditContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory;
use Lc\CaracoleBundle\Repository\Order\OrderReductionCreditRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderReductionCreditStore;

class OrderReductionCreditContainer
{
protected OrderReductionCreditFactory $factory;
protected OrderReductionCreditRepositoryQuery $repositoryQuery;
protected OrderReductionCreditStore $store;

public function __construct(
OrderReductionCreditFactory $factory,
OrderReductionCreditRepositoryQuery $repositoryQuery,
OrderReductionCreditStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderReductionCreditFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderReductionCreditRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderReductionCreditStore
{
return $this->store;
}

}

+ 40
- 0
Container/Order/OrderRefundContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderRefundFactory;
use Lc\CaracoleBundle\Repository\Order\OrderRefundRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderRefundStore;

class OrderRefundContainer
{
protected OrderRefundFactory $factory;
protected OrderRefundRepositoryQuery $repositoryQuery;
protected OrderRefundStore $store;

public function __construct(
OrderRefundFactory $factory,
OrderRefundRepositoryQuery $repositoryQuery,
OrderRefundStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderRefundFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderRefundRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderRefundStore
{
return $this->store;
}

}

+ 87
- 0
Container/Order/OrderShopContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use App\Resolver\OrderShopResolver;
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Definition\Field\Order\OrderShopFieldDefinition;
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory;
use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Transformer\Order\OrderShopTransformer;

class OrderShopContainer
{
protected OrderShopFactory $factory;
protected OrderShopSolver $solver;
protected OrderShopRepositoryQuery $repositoryQuery;
protected OrderShopStore $store;
protected OrderShopBuilder $builder;
protected OrderShopResolver $resolver;
protected OrderShopTransformer $transformer;
protected OrderShopFieldDefinition $fieldDefinition;

public function __construct(
OrderShopFactory $factory,
OrderShopSolver $solver,
OrderShopRepositoryQuery $repositoryQuery,
OrderShopStore $store,
OrderShopResolver $resolver,
OrderShopBuilder $builder,
OrderShopTransformer $transformer,
OrderShopFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->resolver = $resolver;
$this->builder = $builder;
$this->transformer = $transformer;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): OrderShopFactory
{
return $this->factory;
}

public function getSolver(): OrderShopSolver
{
return $this->solver;
}

public function getRepositoryQuery(): OrderShopRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getResolver(): OrderShopResolver
{
return $this->resolver;
}

public function getBuilder(): OrderShopBuilder
{
return $this->builder;
}

public function getTransformer(): OrderShopTransformer
{
return $this->transformer;
}

public function getFieldDefinition(): OrderShopFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 40
- 0
Container/Order/OrderStatusContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderStatusFactory;
use Lc\CaracoleBundle\Repository\Order\OrderStatusRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore;

class OrderStatusContainer
{
protected OrderStatusFactory $factory;
protected OrderStatusRepositoryQuery $repositoryQuery;
protected OrderStatusStore $store;

public function __construct(
OrderStatusFactory $factory,
OrderStatusRepositoryQuery $repositoryQuery,
OrderStatusStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderStatusFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderStatusRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderStatusStore
{
return $this->store;
}

}

+ 40
- 0
Container/Order/OrderStatusHistoryContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Order;

use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory;
use Lc\CaracoleBundle\Repository\Order\OrderStatusHistoryRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderStatusHistoryStore;

class OrderStatusHistoryContainer
{
protected OrderStatusHistoryFactory $factory;
protected OrderStatusHistoryRepositoryQuery $repositoryQuery;
protected OrderStatusHistoryStore $store;

public function __construct(
OrderStatusHistoryFactory $factory,
OrderStatusHistoryRepositoryQuery $repositoryQuery,
OrderStatusHistoryStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OrderStatusHistoryFactory
{
return $this->factory;
}

public function getRepositoryQuery(): OrderStatusHistoryRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): OrderStatusHistoryStore
{
return $this->store;
}

}

+ 59
- 0
Container/PointSale/PointSaleContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\PointSale;

use Lc\CaracoleBundle\Definition\Field\PointSale\PointSaleFieldDefinition;
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory;
use Lc\CaracoleBundle\Repository\PointSale\PointSaleRepositoryQuery;
use Lc\CaracoleBundle\Repository\PointSale\PointSaleStore;
use Lc\CaracoleBundle\Solver\PointSale\PointSaleSolver;

class PointSaleContainer
{
protected PointSaleFactory $factory;
protected PointSaleSolver $solver;
protected PointSaleFieldDefinition $fieldDefinition;
protected PointSaleRepositoryQuery $repositoryQuery;
protected PointSaleStore $store;

public function __construct(
PointSaleFactory $factory,
PointSaleSolver $solver,
PointSaleFieldDefinition $fieldDefinition,
PointSaleRepositoryQuery $repositoryQuery,
PointSaleStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->fieldDefinition = $fieldDefinition;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): PointSaleFactory
{
return $this->factory;
}

public function getSolver(): PointSaleSolver
{
return $this->solver;
}

public function getFieldDefinition(): PointSaleFieldDefinition
{
return $this->fieldDefinition;
}

public function getRepositoryQuery(): PointSaleRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}
}

+ 60
- 0
Container/Product/ProductCategoryContainer.php Просмотреть файл

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

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;
use Lc\CaracoleBundle\Solver\Product\ProductCategorySolver;

class ProductCategoryContainer
{
protected ProductCategoryFactory $factory;
protected ProductCategorySolver $solver;
protected ProductCategoryRepositoryQuery $repositoryQuery;
protected ProductCategoryStore $store;
protected ProductCategoryFieldDefinition $fieldDefinition;

public function __construct(
ProductCategoryFactory $factory,
ProductCategorySolver $solver,
ProductCategoryRepositoryQuery $repositoryQuery,
ProductCategoryStore $store,
ProductCategoryFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ProductCategoryFactory
{
return $this->factory;
}

public function getSolver(): ProductCategorySolver
{
return $this->solver;
}

public function getRepositoryQuery(): ProductCategoryRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getFieldDefinition(): ProductCategoryFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 51
- 0
Container/Product/ProductContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Product;

use Lc\CaracoleBundle\Factory\Product\ProductFactory;
use Lc\CaracoleBundle\Repository\Product\ProductRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductStore;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;

class ProductContainer
{
protected ProductFactory $factory;
protected ProductSolver $solver;
protected ProductRepositoryQuery $repositoryQuery;
protected ProductStore $store;

public function __construct(
ProductFactory $factory,
ProductSolver $solver,
ProductRepositoryQuery $repositoryQuery,
ProductStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): ProductFactory
{
return $this->factory;
}

public function getSolver(): ProductSolver
{
return $this->solver;
}

public function getRepositoryQuery(): ProductRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

}

+ 78
- 0
Container/Product/ProductFamilyContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Product;

use App\Definition\Field\Product\ProductFamilyFieldDefinition;
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\ProductFamilyResolver;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;

class ProductFamilyContainer
{
protected ProductFamilyFactory $factory;
protected ProductFamilySolver $solver;
protected ProductFamilyRepositoryQuery $repositoryQuery;
protected ProductFamilyStore $store;
protected ProductFamilyBuilder $builder;
protected ProductFamilyResolver $resolver;
protected ProductFamilyFieldDefinition $fieldDefinition;

public function __construct(
ProductFamilyFactory $factory,
ProductFamilySolver $solver,
ProductFamilyRepositoryQuery $repositoryQuery,
ProductFamilyStore $store,
ProductFamilyBuilder $builder,
ProductFamilyResolver $resolver,
ProductFamilyFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
$this->resolver = $resolver;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ProductFamilyFactory
{
return $this->factory;
}

public function getSolver(): ProductFamilySolver
{
return $this->solver;
}

public function getRepositoryQuery(): ProductFamilyRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getResolver(): ProductFamilyResolver
{
return $this->resolver;
}

public function getBuilder(): ProductFamilyBuilder
{
return $this->builder;
}


public function getFieldDefinition(): ProductFamilyFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 66
- 0
Container/Product/ProductFamilySectionPropertyContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Product;

use App\Definition\Field\Product\ProductFamilyFieldDefinition;
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder;
use Lc\CaracoleBundle\Builder\Product\ProductFamilySectionPropertyBuilder;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Factory\Product\ProductFamilySectionPropertyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\ProductFamilySectionPropertyStore;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore;
use Lc\CaracoleBundle\Resolver\ProductFamilyResolver;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;

class ProductFamilySectionPropertyContainer
{
protected ProductFamilySectionPropertyFactory $factory;
protected ProductFamilySectionPropertySolver $solver;
protected ProductFamilySectionPropertyRepositoryQuery $repositoryQuery;
protected ProductFamilySectionPropertyStore $store;
protected ProductFamilySectionPropertyBuilder $builder;

public function __construct(
ProductFamilySectionPropertyFactory $factory,
ProductFamilySectionPropertySolver $solver,
ProductFamilySectionPropertyRepositoryQuery $repositoryQuery,
ProductFamilySectionPropertyStore $store,
ProductFamilySectionPropertyBuilder $builder
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
}

public function getFactory(): ProductFamilySectionPropertyFactory
{
return $this->factory;
}

public function getSolver(): ProductFamilySectionPropertySolver
{
return $this->solver;
}

public function getRepositoryQuery(): ProductFamilySectionPropertyRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getBuilder(): ProductFamilySectionPropertyBuilder
{
return $this->builder;
}
}

+ 40
- 0
Container/Product/QualityLabelContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Product;

use Lc\CaracoleBundle\Factory\Product\QualityLabelFactory;
use Lc\CaracoleBundle\Repository\Product\QualityLabelRepositoryQuery;
use Lc\CaracoleBundle\Repository\Product\QualityLabelStore;

class QualityLabelContainer
{
protected QualityLabelFactory $factory;
protected QualityLabelRepositoryQuery $repositoryQuery;
protected QualityLabelStore $store;

public function __construct(
QualityLabelFactory $factory,
QualityLabelRepositoryQuery $repositoryQuery,
QualityLabelStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): QualityLabelFactory
{
return $this->factory;
}

public function getRepositoryQuery(): QualityLabelRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): QualityLabelStore
{
return $this->store;
}

}

+ 50
- 0
Container/Reduction/ReductionCartContainer.php Просмотреть файл

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

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;

class ReductionCartContainer
{
protected ReductionCartFactory $factory;
protected ReductionCartRepositoryQuery $repositoryQuery;
protected ReductionCartStore $store;
protected ReductionCartFieldDefinition $fieldDefinition;

public function __construct(
ReductionCartFactory $factory,
ReductionCartRepositoryQuery $repositoryQuery,
ReductionCartStore $store,
ReductionCartFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ReductionCartFactory
{
return $this->factory;
}

public function getRepositoryQuery(): ReductionCartRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getFieldDefinition(): ReductionCartFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 51
- 0
Container/Reduction/ReductionCatalogContainer.php Просмотреть файл

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

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;

class ReductionCatalogContainer
{
protected ReductionCatalogFactory $factory;
protected ReductionCatalogRepositoryQuery $repositoryQuery;
protected ReductionCatalogStore $store;
protected ReductionCatalogFieldDefinition $fieldDefinition;

public function __construct(
ReductionCatalogFactory $factory,
ReductionCatalogRepositoryQuery $repositoryQuery,
ReductionCatalogStore $store,
ReductionCatalogFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ReductionCatalogFactory
{
return $this->factory;
}

public function getRepositoryQuery(): ReductionCatalogRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getFieldDefinition(): ReductionCatalogFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 49
- 0
Container/Reduction/ReductionCreditContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Reduction;

use App\Definition\Field\Reduction\ReductionCreditFieldDefinition;
use Lc\CaracoleBundle\Factory\Reduction\ReductionCreditFactory;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditRepositoryQuery;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;

class ReductionCreditContainer
{
protected ReductionCreditFactory $factory;
protected ReductionCreditRepositoryQuery $repositoryQuery;
protected ReductionCreditStore $store;
protected ReductionCreditFieldDefinition $fieldDefinition;

public function __construct(
ReductionCreditFactory $factory,
ReductionCreditRepositoryQuery $repositoryQuery,
ReductionCreditStore $store,
ReductionCreditFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ReductionCreditFactory
{
return $this->factory;
}

public function getRepositoryQuery(): ReductionCreditRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): ReductionCreditStore
{
return $this->store;
}

public function getFieldDefinition(): ReductionCreditFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 51
- 0
Container/Section/OpeningContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Section;

use Lc\CaracoleBundle\Factory\Section\OpeningFactory;
use Lc\CaracoleBundle\Repository\Section\OpeningRepositoryQuery;
use Lc\CaracoleBundle\Repository\Section\OpeningStore;
use Lc\CaracoleBundle\Resolver\OpeningResolver;

class OpeningContainer
{
protected OpeningFactory $factory;
protected OpeningResolver $resolver;
protected OpeningRepositoryQuery $repositoryQuery;
protected OpeningStore $store;

public function __construct(
OpeningFactory $factory,
OpeningResolver $resolver,
OpeningRepositoryQuery $repositoryQuery,
OpeningStore $store
) {
$this->factory = $factory;
$this->resolver = $resolver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): OpeningFactory
{
return $this->factory;
}

public function getResolver(): OpeningResolver
{
return $this->resolver;
}

public function getRepositoryQuery(): OpeningRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

}

+ 59
- 0
Container/Section/SectionContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Section;

use Lc\CaracoleBundle\Factory\Section\SectionFactory;
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\CaracoleBundle\Solver\Section\SectionSolver;

class SectionContainer
{
protected SectionFactory $factory;
protected SectionSolver $solver;
protected SectionResolver $resolver;
protected SectionRepositoryQuery $repositoryQuery;
protected SectionStore $store;

public function __construct(
SectionFactory $factory,
SectionSolver $solver,
SectionResolver $resolver,
SectionRepositoryQuery $repositoryQuery,
SectionStore $store
) {
$this->factory = $factory;
$this->solver = $solver;
$this->resolver = $resolver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): SectionFactory
{
return $this->factory;
}

public function getSolver(): SectionSolver
{
return $this->solver;
}

public function getResolver(): SectionResolver
{
return $this->resolver;
}

public function getRepositoryQuery(): SectionRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}
}

+ 60
- 0
Container/Setting/MerchantSettingContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Setting;

use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Factory\Setting\MerchantSettingFactory;
use Lc\CaracoleBundle\Repository\Setting\MerchantSettingRepositoryQuery;
use Lc\CaracoleBundle\Repository\Setting\MerchantSettingStore;
use Lc\SovBundle\Solver\Setting\SettingSolver;

class MerchantSettingContainer
{
protected MerchantSettingFactory $factory;
protected MerchantSettingDefinition $definition;
protected MerchantSettingRepositoryQuery $repositoryQuery;
protected MerchantSettingStore $store;
protected SettingSolver $settingSolver;

public function __construct(
MerchantSettingFactory $factory,
MerchantSettingDefinition $definition,
MerchantSettingRepositoryQuery $repositoryQuery,
MerchantSettingStore $store,
SettingSolver $settingSolver
) {
$this->factory = $factory;
$this->definition = $definition;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->settingSolver = $settingSolver;
}

public function getFactory(): MerchantSettingFactory
{
return $this->factory;
}

public function getDefinition(): MerchantSettingDefinition
{
return $this->definition;
}

public function getRepositoryQuery(): MerchantSettingRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getSettingSolver(): SettingSolver
{
return $this->settingSolver;
}

}

+ 60
- 0
Container/Setting/SectionSettingContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\Setting;

use Lc\CaracoleBundle\Definition\SectionSettingDefinition;
use Lc\CaracoleBundle\Factory\Setting\SectionSettingFactory;
use Lc\CaracoleBundle\Repository\Setting\SectionSettingRepositoryQuery;
use Lc\CaracoleBundle\Repository\Setting\SectionSettingStore;
use Lc\SovBundle\Solver\Setting\SettingSolver;

class SectionSettingContainer
{
protected SectionSettingFactory $factory;
protected SectionSettingDefinition $definition;
protected SectionSettingRepositoryQuery $repositoryQuery;
protected SectionSettingStore $store;
protected SettingSolver $settingSolver;

public function __construct(
SectionSettingFactory $factory,
SectionSettingDefinition $definition,
SectionSettingRepositoryQuery $repositoryQuery,
SectionSettingStore $store,
SettingSolver $settingSolver
) {
$this->factory = $factory;
$this->definition = $definition;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->settingSolver = $settingSolver;
}

public function getFactory(): SectionSettingFactory
{
return $this->factory;
}

public function getDefinition(): SectionSettingDefinition
{
return $this->definition;
}

public function getRepositoryQuery(): SectionSettingRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getSettingSolver(): SettingSolver
{
return $this->settingSolver;
}

}

+ 69
- 0
Container/User/UserMerchantContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\User;

use Lc\CaracoleBundle\Builder\User\UserMerchantBuilder;
use Lc\CaracoleBundle\Definition\Field\User\UserMerchantFieldDefinition;
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory;
use Lc\CaracoleBundle\Repository\User\UserMerchantRepositoryQuery;
use Lc\CaracoleBundle\Repository\User\UserMerchantStore;
use Lc\CaracoleBundle\Solver\User\UserMerchantSolver;

class UserMerchantContainer
{
protected UserMerchantFactory $factory;
protected UserMerchantSolver $solver;
protected UserMerchantRepositoryQuery $repositoryQuery;
protected UserMerchantStore $store;
protected UserMerchantBuilder $builder;
protected UserMerchantFieldDefinition $fieldDefinition;

public function __construct(
UserMerchantFactory $factory,
UserMerchantSolver $solver,
UserMerchantRepositoryQuery $repositoryQuery,
UserMerchantStore $store,
UserMerchantBuilder $builder,
UserMerchantFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->builder = $builder;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): UserMerchantFactory
{
return $this->factory;
}

public function getSolver(): UserMerchantSolver
{
return $this->solver;
}

public function getRepositoryQuery(): UserMerchantRepositoryQuery
{
return $this->repositoryQuery;
}

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

return $this->store;
}

public function getBuilder(): UserMerchantBuilder
{
return $this->builder;
}

public function getFieldDefinition(): UserMerchantFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 40
- 0
Container/User/UserPointSaleContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\User;

use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory;
use Lc\CaracoleBundle\Repository\User\UserPointSaleRepositoryQuery;
use Lc\CaracoleBundle\Repository\User\UserPointSaleStore;

class UserPointSaleContainer
{
protected UserPointSaleFactory $factory;
protected UserPointSaleRepositoryQuery $repositoryQuery;
protected UserPointSaleStore $store;

public function __construct(
UserPointSaleFactory $factory,
UserPointSaleRepositoryQuery $repositoryQuery,
UserPointSaleStore $store
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
}

public function getFactory(): UserPointSaleFactory
{
return $this->factory;
}

public function getRepositoryQuery(): UserPointSaleRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): UserPointSaleStore
{
return $this->store;
}

}

+ 67
- 0
Container/User/VisitorContainer.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Container\User;

use Lc\CaracoleBundle\Builder\User\VisitorBuilder;
use Lc\CaracoleBundle\Factory\User\VisitorFactory;
use Lc\CaracoleBundle\Repository\User\VisitorRepositoryQuery;
use Lc\CaracoleBundle\Repository\User\VisitorStore;
use Lc\CaracoleBundle\Resolver\VisitorResolver;
use Lc\CaracoleBundle\Solver\User\VisitorSolver;

class VisitorContainer
{
protected VisitorFactory $factory;
protected VisitorSolver $solver;
protected VisitorRepositoryQuery $repositoryQuery;
protected VisitorStore $store;
protected VisitorResolver $resolver;
protected VisitorBuilder $visitorBuilder;

public function __construct(
VisitorFactory $factory,
VisitorSolver $solver,
VisitorRepositoryQuery $repositoryQuery,
VisitorStore $store,
VisitorResolver $resolver,
VisitorBuilder $builder
) {
$this->factory = $factory;
$this->solver = $solver;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->resolver = $resolver;
$this->builder = $builder;
}

public function getFactory(): VisitorFactory
{
return $this->factory;
}

public function getSolver(): VisitorSolver
{
return $this->solver;
}

public function getRepositoryQuery(): VisitorRepositoryQuery
{
return $this->repositoryQuery;
}

public function getStore(): VisitorStore
{
return $this->store;
}

public function getResolver(): VisitorResolver
{
return $this->resolver;
}

public function getBuilder(): VisitorBuilder
{
return $this->builder;
}

}

+ 17
- 0
Context/MerchantContextTrait.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Context;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

trait MerchantContextTrait
{
protected MerchantInterface $merchant;

public function setMerchant(MerchantInterface $merchant)
{
$this->merchant = $merchant;

return $this;
}
}

+ 17
- 0
Context/SectionContextTrait.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Context;

use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait SectionContextTrait
{
protected ?SectionInterface $section = null;

public function setSection(?SectionInterface $section)
{
$this->section = $section;

return $this;
}
}

+ 10
- 0
Controller/AbstractAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller;

use Lc\SovBundle\Controller\AbstractAdminController as SovAbstractAdminController;

abstract class AbstractAdminController extends SovAbstractAdminController
{
use AdminControllerTrait;
}

+ 10
- 0
Controller/AbstractController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller;

use Lc\SovBundle\Controller\AbstractController as SovAbstractController;

abstract class AbstractController extends SovAbstractController
{
use ControllerTrait;
}

+ 92
- 0
Controller/Address/AddressApiController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Address;

use Lc\CaracoleBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;

class AddressApiController extends AbstractController
{
/**
* @Route("/api-cities", name="api_cities")
*/
public function cities(Request $request): JsonResponse
{
$citiesComponent = $this->getComponentContainer()->getCitiesComponent();
$term = $request->get('term');
$context = $request->get('context');
$data = [
'boost' => 'population',
];

if (strlen($term) == 5 && is_numeric($term)) {
$data['codePostal'] = $term;
} else {
$data['nom'] = $term;
}

$result = array_merge(
json_decode($citiesComponent->callCitiesApi('get', 'communes', array_merge($data, ['codeRegion' => 27]))),
json_decode($citiesComponent->callCitiesApi('get', 'communes', array_merge($data, ['codeRegion' => 44])))
);

$return = [];
foreach ($result as $city) {
$codesPostaux = $city->codesPostaux;

if ($context == 'frontend') {
$label = '<span class="city">' . $city->nom . '</span> <span class="zip">' . $codesPostaux[0] . '</span>';
} else {
$label = $city->nom . ' - ' . $codesPostaux[0];
}

$return[] = [
'label' => $label,
'city' => $city->nom,
'value' => $city->code
];
}

if ($context == 'frontend') {
$return = [
'items' => $return
];
}

return new JsonResponse($return);
}

/**
* @Route("/api-addresses", name="api_addresses")
*/
public function addresses(Request $request): JsonResponse
{
$citiesComponent = $this->getComponentContainer()->getCitiesComponent();
$return = [];
$address = $request->get('address');
$context = $request->get('context');
$results = $citiesComponent->callAddressApi($address);

foreach ($results as $result) {
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) {
$streetNameNumber = $result->getStreetNumber() . ' ' . $result->getStreetName();
$return[] = [
'label' => $streetNameNumber,
'value' => $streetNameNumber,
'latitude' => $result->getCoordinates()->getLatitude(),
'longitude' => $result->getCoordinates()->getLongitude()
];
}
}

if ($context == 'frontend') {
$return = [
'items' => $return
];
}

return new JsonResponse($return);
}
}

+ 275
- 0
Controller/AdminControllerTrait.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
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\Definition\ActionDefinition;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Form\Merchant\DuplicateToOtherMerchantFormType;
use Lc\CaracoleBundle\Form\Section\DuplicateToOtherSectionFormType;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use Lc\SovBundle\Component\EntityComponent;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\Response;

trait AdminControllerTrait
{
use ControllerTrait;

public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

$this->configureResponseParametersFilterSection($responseParameters);

return $responseParameters;
}

public function configureResponseParametersFilterSection(KeyValueStore $responseParameters)
{
if ($this->isInstanceOf(FilterSectionInterface::class)) {
$responseParameters->set('display_switch_section', true);
}
}

public function configureResponseParametersDisableShowAllSections(KeyValueStore $responseParameters)
{
if($this->getSectionCurrent() == null) {
$responseParameters->set('replace_content_with_message', "Vous devez sélectionner une section pour afficher ces données.");
}
}

public function createIndexRepositoryQuery(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): RepositoryQueryInterface {
$repositoryQuery = parent::createIndexRepositoryQuery(
$searchDto,
$entityDto,
$fields,
$filters
);

$sectionCurrent = $this->get(SectionResolver::class)->getCurrent();

if ($this->isInstanceOf(FilterMerchantInterface::class)
|| $this->isInstanceOf(FilterMultipleMerchantsInterface::class)) {
$repositoryQuery->filterByMerchant($this->getMerchantCurrent());
}

if ($sectionCurrent && $this->isInstanceOf(FilterSectionInterface::class)) {
$repositoryQuery->filterBySection($sectionCurrent);
}

if ($this->isOutOfSection() && $this->isInstanceOf(FilterSectionInterface::class) && !$this->isInstanceOf(FilterMerchantInterface::class)) {
$repositoryQuery->filterByMerchantViaSection($this->getMerchantCurrent());
}

return $repositoryQuery;
}


public function duplicateToOtherMerchant(
AdminContext $context,
EntityComponent $entityComponent,
TranslatorAdmin $translatorAdmin,
EntityManagerInterface $em
) {
if (!$this->isGranted(
Permission::EA_EXECUTE_ACTION,
['action' => "duplicate", 'entity' => $context->getEntity()]
)) {
throw new ForbiddenActionException($context);
}

if (!$context->getEntity()->isAccessible()) {
throw new InsufficientEntityPermissionException($context);
}

if (!$this->isInstanceOf(FilterMerchantInterface::class)) {
throw new \ErrorException('L\entité n\'est pas lié à un merchant.');
}
$duplicateOtherMerchantForm = $this->createForm(
DuplicateToOtherMerchantFormType::class,
null,
array(
'entityClass' => $context->getEntity()->getFqcn(),
'entityId' => $context->getEntity()->getInstance()->getId(),
'action' => $context->getRequest()->getUri(),
'attr' => ['id' => 'duplicate-other-merchant-form'],

)
);

$duplicateOtherMerchantForm->handleRequest($context->getRequest());

if ($duplicateOtherMerchantForm->isSubmitted() && $duplicateOtherMerchantForm->isValid()) {
$newEntity = $entityComponent->duplicateEntity($context->getEntity()->getInstance());
$em->create($newEntity);
$merchant = $duplicateOtherMerchantForm->get('merchants')->getData();
$newEntity->setMerchant($merchant);
$em->update($newEntity);
$em->flush();

$url = $this->get(AdminUrlGenerator::class)
->setAction(ActionDefinition::EDIT)
->setEntityId($newEntity->getId())
->generateUrl();
$this->addFlashTranslator(
'success',
'duplicateToOtherMerchant',
$this->getTranslationEntityName(),
['%merchant%' => $merchant->getTitle()]
);

//TODO switch merchant route
return $this->redirect($url);
}


if ($context->getRequest()->isXmlHttpRequest()) {
$response['data'] = $this->renderView(
'@LcCaracole/admin/merchant/modal/duplicate_entity_to_other_merchant.html.twig',
array(
'form_duplicate_entity_to_other_merchant' => $duplicateOtherMerchantForm->createView(),
)
);

return new Response(json_encode($response));
} else {
throw new \ErrorException('La requête doit être effectué en ajax');
}
}

public function duplicateToOtherSection(
AdminContext $context,
EntityComponent $entityComponent,
TranslatorAdmin $translatorAdmin,
EntityManagerInterface $em
) {
if (!$this->isGranted(
Permission::EA_EXECUTE_ACTION,
['action' => ActionDefinition::DUPLICATE, 'entity' => $context->getEntity()]
)) {
throw new ForbiddenActionException($context);
}

if (!$context->getEntity()->isAccessible()) {
throw new InsufficientEntityPermissionException($context);
}

if (!$this->isInstanceOf(FilterSectionInterface::class)) {
throw new \ErrorException('L\entité n\'est pas lié à un merchant.');
}
$duplicateOtherSectionForm = $this->createForm(
DuplicateToOtherSectionFormType::class,
null,
array(
'entityClass' => $context->getEntity()->getFqcn(),
'entityId' => $context->getEntity()->getInstance()->getId(),
'action' => $context->getRequest()->getUri(),
'attr' => ['id' => 'duplicate-other-section-form'],
)
);

$duplicateOtherSectionForm->handleRequest($context->getRequest());

if ($duplicateOtherSectionForm->isSubmitted() && $duplicateOtherSectionForm->isValid()) {
$newEntity = $entityComponent->duplicateEntity($context->getEntity()->getInstance());
$em->create($newEntity);
$section = $duplicateOtherSectionForm->get('sections')->getData();
$newEntity->setSection($section);
$em->update($newEntity);
$em->flush();

$url = $this->get(AdminUrlGenerator::class)
->setAction(ActionDefinition::EDIT)
->setEntityId($newEntity->getId())
->generateUrl();
$this->addFlashTranslator(
'success',
'duplicateToOtherSection',
$this->getTranslationEntityName(),
['%section%' => $section->getTitle()]
);

//TODO switch merchant route
return $this->redirect($url);
}


if ($context->getRequest()->isXmlHttpRequest()) {
$response['data'] = $this->renderView(
'@LcCaracole/admin/merchant/modal/duplicate_entity_to_other_section.html.twig',
array(
'form_duplicate_entity_to_other_section' => $duplicateOtherSectionForm->createView(),
)
);

return new Response(json_encode($response));
} else {
throw new \ErrorException('La requête doit être effectué en ajax');
}
}

public function buildIndexActions(Actions $actions): void
{
parent::buildIndexActions($actions);
if ($this->isInstanceOf(FilterMerchantInterface::class)) {
$actions->add(Crud::PAGE_INDEX, $this->getDuplicateToOhterMerchantAction());
}

if ($this->isInstanceOf(FilterSectionInterface::class)) {
$actions->add(Crud::PAGE_INDEX, $this->getDuplicateToOhterSectionAction());
}
}

public function getDuplicateToOhterMerchantAction(): Action
{
$duplicateAction = Action::new(
ActionDefinition::DUPLICATE_TO_OTHER_MERCHANT,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE_TO_OTHER_MERCHANT),
'fa fa-fw fa-copy'
)
->linkToCrudAction(ActionDefinition::DUPLICATE_TO_OTHER_MERCHANT)
->setCssClass('text-info in-dropdown duplicate-to-other-merchant duplicate-modal-action');

return $duplicateAction;
}

public function getDuplicateToOhterSectionAction(): Action
{
$duplicateAction = Action::new(
ActionDefinition::DUPLICATE_TO_OTHER_SECTION,
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE_TO_OTHER_SECTION),
'fa fa-fw fa-copy'
)
->linkToCrudAction(ActionDefinition::DUPLICATE_TO_OTHER_SECTION)
->setCssClass('text-info in-dropdown duplicate-to-other-section duplicate-modal-action');

return $duplicateAction;
}


}


+ 0
- 35
Controller/Common/TaxRateCrudController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Common;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Controller\Admin\AbstractCrudController;

abstract class TaxRateCrudController extends AbstractCrudController
{

public function configureCrud(Crud $crud): Crud
{
return $crud->setSearchFields(['id', 'title', 'value']);
}

public function configureFields(string $pageName): iterable
{
$id = IntegerField::new('id', 'ID');
$title = TextField::new('title');
$value = NumberField::new('value');

if (Crud::PAGE_INDEX === $pageName) {
return [$id, $title, $value];
} elseif (Crud::PAGE_DETAIL === $pageName) {
return [$id, $title, $value];
} elseif (Crud::PAGE_NEW === $pageName) {
return [$title, $value];
} elseif (Crud::PAGE_EDIT === $pageName) {
return [$title, $value];
}
}
}

+ 40
- 0
Controller/Config/TaxRateAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Config;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Config\TaxRateContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Config\TaxRateFactory;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class TaxRateAdminController extends AbstractAdminController
{
use AdminControllerTrait;

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

public function configureFields(string $pageName): iterable
{
return [
TextField::new('title'),
NumberField::new('value')
];
}

public function configureCrud(Crud $crud): Crud
{
return $crud->setSearchFields(['id', 'title', 'value']);
}

public function createEntity(string $entityFqcn)
{
return $this->get(TaxRateContainer::class)->getFactory()->create();
}
}

+ 41
- 0
Controller/Config/UnitAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Config;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Config\UnitContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Config\UnitFactory;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class UnitAdminController extends AbstractAdminController
{
use AdminControllerTrait;
public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(UnitContainer::class)->getRepositoryQuery();
}

public function configureFields(string $pageName): iterable
{
return [
TextField::new('unit'),
TextField::new('wording'),
TextField::new('wordingUnit'),
TextField::new('wordingShort'),
IntegerField::new('coefficient'),
AssociationField::new('unitReference')
->setCustomOption('filter', false),
];
}

public function createEntity(string $entityFqcn)
{
return $this->get(UnitContainer::class)->getFactory()->create();
}
}

+ 356
- 0
Controller/ControllerTrait.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller;

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\Distribution\DistributionContainer;
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\Product\ProductFamilySectionPropertyContainer;
use Lc\CaracoleBundle\Container\Product\QualityLabelContainer;
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\Model\Merchant\MerchantInterface;
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;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Symfony\Component\Security\Core\Security;

trait ControllerTrait
{
public static function getSubscribedServices()
{
return array_merge(
parent::getSubscribedServices(),
[
MailMailjetNotification::class => MailMailjetNotification::class,
PriceSolver::class => PriceSolver::class,
MerchantResolver::class => MerchantResolver::class,
SectionResolver::class => SectionResolver::class,
OrderShopContainer::class => OrderShopContainer::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,
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,
DistributionContainer::class => DistributionContainer::class,
ProductFamilySectionPropertyContainer::class => ProductFamilySectionPropertyContainer::class,
QualityLabelContainer::class => QualityLabelContainer::class,
]
);
}

public function getMailMailjetNotification()
{
return $this->get(MailMailjetNotification::class);
}

public function getMerchantSettingCurrent(string $settingName)
{
return $this->getSettingValue($this->getMerchantCurrent(), $settingName);
}

public function getSectionSettingCurrent(string $settingName)
{
return $this->getSettingValue($this->getSectionCurrent(), $settingName);
}

public function getSettingSolver(): SettingSolver
{
return $this->get(SettingSolver::class);
}

public function getSettingValue($entity, $settingName)
{
return $this->getSettingSolver()->getSettingValue($entity, $settingName);
}

public function getUserCurrent(): ?UserInterface
{
return $this->get(Security::class)->getUser();
}

public function getVisitorCurrent(): VisitorInterface
{
return $this->getVisitorContainer()->getResolver()->getCurrent();
}

public function getMerchantCurrent(): MerchantInterface
{
return $this->get(MerchantResolver::class)->getCurrent();
}

public function getUserMerchantCurrent(): UserMerchantInterface
{
return $this->getUserMerchantContainer()->getBuilder()->createIfNotExist(
$this->getUserCurrent(),
$this->getMerchantCurrent()
);
}

public function getMerchantUserCurrent(): MerchantInterface
{
return $this->get(MerchantResolver::class)->getMerchantUser($this->getUserCurrent());
}

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

public function getSectionCurrentDefault(): ?SectionInterface
{
return $this->get(SectionResolver::class)->getCurrent(true);
}

public function getSectionCurrentVisited(): ?SectionInterface
{
return $this->get(SectionResolver::class)->getCurrent(false, true);
}

public function isOutOfSection()
{
return $this->get(SectionResolver::class)->isOutOfSection();
}

public function getSectionCurrentSlug(): string
{
return $this->getSectionCurrent()->getSlug();
}

public function getCartCurrent(): OrderShopInterface
{
return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
$this->getSectionCurrent(),
$this->getUserCurrent(),
$this->getVisitorCurrent(),
true
);
}

public function getCartCurrentVisited(): OrderShopInterface
{
return $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
$this->getSectionCurrentVisited(),
$this->getUserCurrent(),
$this->getVisitorCurrent(),
true
);
}

public function getPriceSolver(): PriceSolver
{
return $this->get(PriceSolver::class);
}

public function getOrderShopContainer(): OrderShopContainer
{
return $this->get(OrderShopContainer::class);
}

public function getAddressContainer(): AddressContainer
{
return $this->get(AddressContainer::class);
}

public function getTaxRateContainer(): TaxRateContainer
{
return $this->get(TaxRateContainer::class);
}

public function getUnitContainer(): UnitContainer
{
return $this->get(UnitContainer::class);
}

public function getCreditHistoryContainer(): CreditHistoryContainer
{
return $this->get(CreditHistoryContainer::class);
}

public function getDocumentContainer(): DocumentContainer
{
return $this->get(DocumentContainer::class);
}

public function getMerchantContainer(): MerchantContainer
{
return $this->get(MerchantContainer::class);
}

public function getOrderPaymentContainer(): OrderPaymentContainer
{
return $this->get(OrderPaymentContainer::class);
}

public function getOrderProductContainer(): OrderProductContainer
{
return $this->get(OrderProductContainer::class);
}

public function getOrderProductReductionCatalogContainer(): OrderProductReductionCatalogContainer
{
return $this->get(OrderProductReductionCatalogContainer::class);
}

public function getOrderProductRefundContainer(): OrderProductRefundContainer
{
return $this->get(OrderProductRefundContainer::class);
}

public function getOrderReductionCartContainer(): OrderReductionCartContainer
{
return $this->get(OrderReductionCartContainer::class);
}

public function getOrderReductionCreditContainer(): OrderReductionCreditContainer
{
return $this->get(OrderReductionCreditContainer::class);
}

public function getOrderRefundContainer(): OrderRefundContainer
{
return $this->get(OrderRefundContainer::class);
}

public function getOrderStatusContainer(): OrderStatusContainer
{
return $this->get(OrderStatusContainer::class);
}

public function getOrderStatusHistoryContainer(): OrderStatusHistoryContainer
{
return $this->get(OrderStatusHistoryContainer::class);
}

public function getPointSaleContainer(): PointSaleContainer
{
return $this->get(PointSaleContainer::class);
}

public function getProductCategoryContainer(): ProductCategoryContainer
{
return $this->get(ProductCategoryContainer::class);
}

public function getProductContainer(): ProductContainer
{
return $this->get(ProductContainer::class);
}

public function getProductFamilyContainer(): ProductFamilyContainer
{
return $this->get(ProductFamilyContainer::class);
}

public function getReductionCartContainer(): ReductionCartContainer
{
return $this->get(ReductionCartContainer::class);
}

public function getReductionCatalogContainer(): ReductionCatalogContainer
{
return $this->get(ReductionCatalogContainer::class);
}

public function getReductionCreditContainer(): ReductionCreditContainer
{
return $this->get(ReductionCreditContainer::class);
}

public function getOpeningContainer(): OpeningContainer
{
return $this->get(OpeningContainer::class);
}

public function getSectionContainer(): SectionContainer
{
return $this->get(SectionContainer::class);
}

public function getMerchantSettingContainer(): MerchantSettingContainer
{
return $this->get(MerchantSettingContainer::class);
}

public function getSectionSettingContainer(): SectionSettingContainer
{
return $this->get(SectionSettingContainer::class);
}

public function getUserMerchantContainer(): UserMerchantContainer
{
return $this->get(UserMerchantContainer::class);
}

public function getUserPointSaleContainer(): UserPointSaleContainer
{
return $this->get(UserPointSaleContainer::class);
}

public function getVisitorContainer(): VisitorContainer
{
return $this->get(VisitorContainer::class);
}

public function getQualityLabelContainer(): QualityLabelContainer
{
return $this->get(QualityLabelContainer::class);
}
}

+ 127
- 0
Controller/Credit/CreditHistoryAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Credit;

use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer;
use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Definition\ActionDefinition;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Solver\Credit\CreditHistorySolver;
use Lc\CaracoleBundle\Solver\Order\OrderPaymentSolver;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class CreditHistoryAdminController extends AbstractAdminController
{

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

public function overrideGlobalActions(?ActionCollection $actions): void
{
parent::overrideGlobalActions($actions);
if ($actions) {
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);

$creditControllerFqcn = $this->getControllerFqcnByInterface(CreditHistoryInterface::class);

foreach ($actions as $action) {
$url = $adminUrlGenerator
->setController($creditControllerFqcn)
->setAction(ActionDefinition::NEW)
->set('userMerchantId', $this->getUserMerchant()->getId())
->generateUrl();
$action->setLinkUrl($url);
}
}
}

public function createEntity(string $entityFqcn)
{
return $this->get(CreditHistoryContainer::class)->getFactory()->createBase($this->getUserMerchant());
}

protected function getUserMerchant(): UserMerchantInterface
{
$request = $this->get(AdminContextProvider::class)->getContext()->getRequest();
return $this->get(UserMerchantContainer::class)->getStore()->getOneById(
$request->get('userMerchantId')
);
}

public function configureActions(Actions $actions): Actions
{
$actions = parent::configureActions($actions);
$actions->disable(ActionDefinition::DELETE, ActionDefinition::EDIT, ActionDefinition::DUPLICATE);

return $actions;
}

public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void
{
if ($this->get(CreditHistoryContainer::class)->getBuilder()->save($entityInstance)) {
$this->addFlashTranslator('success', 'saveCreditHistory');
} else {
$this->addFlashTranslator('error', 'saveCreditHistory');
}
}


public function configureCrud(Crud $crud): Crud
{
$crud->overrideTemplate('crud/index', '@LcCaracole/admin/credit/index_credithistory.html.twig');

return $crud;
}

public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

$responseParameters->set('user_merchant', $this->getUserMerchant());
return $responseParameters;
}

public function configureFields(string $pageName): iterable
{
return $this->getCreditHistoryContainer()->getFieldDefinition()->getFields($pageName);

}

public function createIndexRepositoryQuery(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): RepositoryQueryInterface {
$repositoryQuery = parent::createIndexRepositoryQuery(
$searchDto,
$entityDto,
$fields,
$filters
);
$repositoryQuery->filterByUserMerchant($this->getUserMerchant());

return $repositoryQuery;
}
}

+ 49
- 0
Controller/Dashboard/DashboardAdminAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Dashboard;

use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Controller\Dashboard\DashboardAdminController as SovDashboardController;
use Symfony\Component\Security\Core\User\UserInterface;

class DashboardAdminAdminController extends SovDashboardController
{
use ControllerTrait;

public function configureCrud(): Crud
{
$crud = parent::configureCrud();

$crud
->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig');

return $crud;
}

public function configureAssets(): Assets
{
$assets = parent::configureAssets(); // TODO: Change the autogenerated stub

$assets->addWebpackEncoreEntry('carac-common');
$assets->addWebpackEncoreEntry('carac-switch-merchant');
$assets->addWebpackEncoreEntry('carac-duplicate');

return $assets;
}

public function configureUserMenu(UserInterface $user): UserMenu
{
return parent::configureUserMenu($user)
->setMenuItems(
[
MenuItem::linkToRoute('Mon profil', 'fa fa-id-card', 'sov_admin_account_profile'),
MenuItem::linkToLogout('Déconnexion', 'sign-out-alt'),
]
);
}

}

+ 48
- 0
Controller/Merchant/FavoriteMerchantController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Merchant;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
use Lc\CaracoleBundle\Controller\AbstractController;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Routing\Annotation\Route;

class FavoriteMerchantController extends AbstractController
{
/**
* @Route("/merchant/favorite", name="carac_merchant_favorite")
*/
public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $entityManager)
{
$form = $this->createForm(SwitchMerchantFormType::class);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$merchant = $form->get('merchant')->getData();

if ($merchant) {

$user = $security->getUser();
if($user) {
$user->setFavoriteMerchant($merchant);
$entityManager->update($user);
$entityManager->flush();
}

// @TODO : à fignoler, hein gamin ?
$url = $this->getSettingSolver()->getSettingValue(
$merchant,
MerchantSettingDefinition::SETTING_URL
) . 'admin';

if ($url) {
return $this->redirect($url);
}
}
}
}
}

+ 59
- 0
Controller/Merchant/MerchantAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Merchant;

use App\Entity\Merchant\Merchant;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Merchant\MerchantFactory;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class MerchantAdminController extends AbstractAdminController
{
use AdminControllerTrait;

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

public function configureFields(string $pageName): iterable
{
$panel = parent::configureFields($pageName);

return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
NumberField::new('position')
->hideOnForm()
->hideOnIndex(),
CKEditorField::new('description')
->hideOnIndex(),
AssociationField::new('taxRate')
->setRequired(true)
->hideOnIndex(),
StatusField::new('status'),

FormField::addPanel('address'),
AddressField::new('address')
->setRequired(true),
],
$panel
);
}

public function createEntity(string $entityFqcn)
{
return $this->get(MerchantContainer::class)->getFactory()->create();
}

}

+ 43
- 0
Controller/Merchant/SwitchMerchantController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Merchant;

use Lc\CaracoleBundle\Container\Merchant\MerchantContainer;
use Lc\CaracoleBundle\Controller\AbstractController;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Form\Merchant\SwitchMerchantFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class SwitchMerchantController extends AbstractController
{
/**
* @Route("/merchant/switch", name="carac_merchant_switch")
*/
public function switchMerchant(Request $request)
{
$form = $this->createForm(SwitchMerchantFormType::class);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$merchant = $form->get('merchant')->getData();
$context = $form->get('context')->getData();

if ($merchant) {
$url = $this->getSettingValue(
$merchant,
MerchantSettingDefinition::SETTING_URL
);

if ($context == 'admin') {
$url .= 'admin';
}

if ($url) {
return $this->redirect($url);
}
}
}
}

}

+ 28
- 0
Controller/Newsletter/NewsletterAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Newsletter;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Controller\Newsletter\NewsletterAdminController as SovNewsletterAdminController;

abstract class NewsletterAdminController extends SovNewsletterAdminController
{
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->get(NewsletterContainer::class)
->getFactory()
->setSection($this->getSectionCurrent())
->create();
}

public function configureFields(string $pageName): iterable
{
return $this->getNewsletterContainer()->getFieldDefinition()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->getFields($pageName);
}
}

+ 178
- 0
Controller/Order/CartController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Order;

use Lc\CaracoleBundle\Controller\AbstractController;
use Lc\CaracoleBundle\Form\Order\OrderProductsType;
use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class CartController extends AbstractController
{
protected ProductFamilyInterface $productFamily;
protected array $orderProducts = [];

public function addProductFamily(Request $request): JsonResponse
{
$user = $this->getUserCurrent();
$visitor = $this->getVisitorCurrent();

$return = [];
$data = $request->request->all();

if (isset($data['order_products']['id_product_family'])) {
$idProductFamily = $data['order_products']['id_product_family'];
$this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);

// alerte si cookies non acceptés
if (!$user && !$visitor) {
$this->addFlash(
'error',
'Vous devez <a href="' . $this->getRouter()->generate(
'frontend_page',
['devAlias' => 'politique-de-confidentialite']
) . '">accepter les cookies</a> ou vous <a href="' . $this->getRouter()->generate(
'fos_user_security_login'
) . '">connecter</a> pour ajouter un produit.'
);
return false;
}

if ($this->productFamily) {
$form = $this->createForm(
OrderProductsType::class,
['id_product_family' => $this->productFamily->getId()]
);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

$orderShop = $this->getOrderShopContainer()->getBuilder()->createIfNotExist(
$this->getSectionCurrent(),
$this->getUserCurrent(),
$this->getVisitorCurrent()
);

$data = $form->getData();
foreach ($data as $orderProduct) {
if ($orderProduct instanceof OrderProductInterface) {
if ($orderProduct->getQuantityOrder() > 0) {
$addOrderProduct = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderShop,
$orderProduct
);
}
if (isset($addOrderProduct) && $addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct;
}
}
}
}
}
}

return new JsonResponse($return);
}

/**
* @Route("/order-reduction-cart/delete/{id}", name="frontend_cart_delete_reduction_cart")
*/
public function deleteReductionCart(Request $request): RedirectResponse
{
$entityManager = $this->getEntityManager();
$id = $request->get('id');
$orderReductionCart = $this->getOrderReductionCartContainer()->getStore()->getOneById((int) $id);
$orderShop = $this->getCartCurrent();

if ($orderReductionCart && $orderShop->getOrderReductionCarts() && $orderShop->getOrderReductionCarts(
)->contains($orderReductionCart)) {
$entityManager->remove($orderReductionCart);
$entityManager->flush();

$this->addFlash('success', 'La réduction a bien été supprimée de votre panier.');
} else {
$this->addFlash('error', 'Une erreur est survenue lors de la suppression de la réduction. ');
}

return $this->redirectToReferer($request);
}

/**
* @Route("/reduction-credit/add/{id}", name="frontend_order_cart_reduction_credit")
*/
public function addReductionCredit(Request $request): RedirectResponse
{
$id = $request->get('id');
$orderShop = $this->getCartCurrent();
$user = $this->getUserCurrent();
$orderShopContainer = $this->getOrderShopContainer();
$reductionCredit = $this->getReductionCreditContainer()->getStore()->getOneById($id);

if ($orderShop && $user && $reductionCredit
&& $orderShopContainer->getStore()->isReductionCreditAllowAddToOrder($orderShop, $reductionCredit)
&& !$orderShopContainer->getSolver()->isReductionCreditAddedToOrder($orderShop, $reductionCredit)) {
$return = $orderShopContainer->getBuilder()->addReductionCredit($orderShop, $reductionCredit);

if ($return) {
$this->addFlash('success', 'Votre avoir a bien été ajouté à votre panier.');
} else {
$this->addFlash(
'error',
'Vous ne pouvez pas effectuer cette action. Le montant de la commande est insuffisant.'
);
}
} else {
$this->addFlash('error', "Impossible d'effectuer cette action");
}

return $this->redirectToReferer($request);
}

/**
* @Route("/order-reduction-credit/delete/{id}", name="frontend_cart_delete_reduction_credit")
*/
public function deleteReductionCredit(Request $request): RedirectResponse
{
$entityManager = $this->getEntityManager();
$id = $request->get('id');
$orderReductionCredit = $this->getOrderReductionCreditContainer()->getStore()->getOneById((int)$id);
$orderShop = $this->getCartCurrent();

if ($orderReductionCredit && $orderShop->getOrderReductionCredits() && $orderShop->getOrderReductionCredits(
)->contains($orderReductionCredit)) {
$entityManager->remove($orderReductionCredit);
$entityManager->flush();

$this->addFlash('success', 'Votre avoir a bien été supprimé de votre panier.');
} else {
$this->addFlash('error', 'Une erreur est survenue lors de la suppression de votre avoir. ');
}

$referer = $this->getReferer($request);

if ($referer) {
return $this->redirect($referer);
} else {
return $this->redirectToRoute('frontend_order_cart', [
'section' => $this->getSectionCurrentSlug()
]);
}
}

protected function redirectToReferer(Request $request): RedirectResponse
{
$referer = $this->getReferer($request);

if ($referer) {
return $this->redirect($referer);
} else {
return $this->redirectToRoute('frontend_order_cart', [
'section' => $this->getSectionCurrentSlug()
]);
}
}
}

+ 25
- 0
Controller/Order/OrderShopAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Order;


use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\CaracoleBundle\Model\Config\UnitModel;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

abstract class OrderShopAdminController extends AbstractAdminController
{
use AdminControllerTrait;

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

+ 23
- 0
Controller/Order/OrderStatusAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Order;

use Lc\CaracoleBundle\Container\Order\OrderStatusContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class OrderStatusAdminController extends AbstractAdminController
{
use AdminControllerTrait;

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

public function createEntity(string $entityFqcn)
{
return $this->getOrderStatusContainer()->getFactory()->create();
}
}

+ 32
- 0
Controller/PointSale/PointSaleAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\PointSale;

use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class PointSaleAdminController extends AbstractAdminController
{
use AdminControllerTrait;

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

public function configureFields(string $pageName): iterable
{
return $this->getPointSaleContainer()
->getFieldDefinition()
->getFields($pageName);
}

public function createEntity(string $entityFqcn)
{
return $this->get(PointSaleContainer::class)
->getFactory()
->create($this->getMerchantCurrent());
}
}

+ 101
- 0
Controller/Product/FavoriteController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Product;

use Lc\CaracoleBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class FavoriteController extends AbstractController
{
/**
* @Route("/favorite/toggle", name="lc_frontend_favorite_toggle")
*/
public function toggle(Request $request)
{
$user = $this->_getUser();
$productFamily = $this->_getProductFamily($request);

if ($user->getFavoriteProductFamilies()->contains($productFamily)) {
$user->removeFavoriteProductFamily($productFamily);
$isFavorite = false;
$message = 'Le produit a bien été supprimé de vos favoris';
} else {
$user->addFavoriteProductFamily($productFamily);
$isFavorite = true;
$message = 'Le produit a bien été ajouté à vos favoris';
}

$this->_saveUser($user);

return new JsonResponse([
'return' => 'success',
'is_favorite' => $isFavorite,
'message' => $message
]);
}

/**
* @Route("/favorite/add", name="lc_frontend_favorite_add")
*/
public function add(Request $request)
{
$user = $this->_getUser();
$productFamily = $this->_getProductFamily($request);

$user->addFavoriteProductFamily($productFamily);
$this->_saveUser($user);

return new JsonResponse([
'return' => 'success',
'message' => 'Le produit a bien été ajouté à vos favoris'
]);
}

/**
* @Route("/favorite/delete", name="lc_frontend_favorite_delete")
*/
public function delete(Request $request)
{
$user = $this->_getUser();
$productFamily = $this->_getProductFamily($request);

$user->removeFavoriteProductFamily($productFamily);
$this->_saveUser($user);

return new JsonResponse([
'return' => 'success',
'message' => 'Le produit a bien été supprimé de vos favoris'
]);
}

private function _getUser()
{
$user = $this->getUserCurrent();
if (!$user) {
throw new \ErrorException('Vous devez être connecté pour gérer vos favoris');
}

return $user;
}

private function _saveUser($user)
{
$entityManager = $this->getEntityManager();
$entityManager->persist($user);
$entityManager->flush();
}

private function _getProductFamily($request)
{
$idProductFamily = $request->request->get('idProductFamily');
$productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily);

if ($productFamily) {
return $productFamily;
} else {
throw new \ErrorException('Ce produit est introuvable');
}
}
}

+ 49
- 0
Controller/Product/ProductCategoryAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Product;

use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Definition\ActionDefinition;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Field\ToggleField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class ProductCategoryAdminController extends AbstractAdminController
{
public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->getProductCategoryContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getProductCategoryContainer()->getFactory()->create($this->getSectionCurrent());
}

public function configureFields(string $pageName): iterable
{
return $this->getProductCategoryContainer()->getFieldDefinition()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->getFields($pageName);
}

public function configureActions(Actions $actions): Actions
{
$actions = parent::configureActions($actions);

if(!$this->getSectionCurrent()) {
$actions->disable(ActionDefinition::NEW);
}

return $actions;
}
}

+ 67
- 0
Controller/Product/ProductFamilyAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Product;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Response;

abstract class ProductFamilyAdminController extends AbstractAdminController
{
public function configureCrud(Crud $crud): Crud
{
$crud = parent::configureCrud($crud);

$crud->setDefaultSort(['id' => 'DESC']);

return $crud;
}

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

public function createEntity(string $entityFqcn)
{
return $this->getProductFamilyContainer()
->getFactory()
->create($this->getMerchantCurrent());
}


public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

// affichage du filtre sur section
$responseParameters->set('display_switch_section', true);

return $responseParameters;
}

public function showSalesStatistic(AdminContext $context)
{
$productFamily = $context->getEntity()->getInstance();

$currentSection = $this->get(SectionResolver::class)->getCurrent();
$productsSalesStatistic = $this->get(OrderShopContainer::class)->getBuilder()->getProductsSalesStatistic($currentSection, $productFamily, 16);
$parameters = array(
'productFamily' => $productFamily,
'productsSalesStatistic' => $productsSalesStatistic
);

//TODO flashMessages ???
$response['flashMessages'] = [];//$this->utils->getFlashMessages();
$response['data'] = $this->render('@LcCaracole/admin/product/modal/show_products_sales_statistic.html.twig', $parameters)->getContent();
$response['statistics'] = $productsSalesStatistic;
return new Response(json_encode($response));
}

}

+ 32
- 0
Controller/Product/QualityLabelAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Product;

use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class QualityLabelAdminController extends AbstractAdminController
{

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->getQualityLabelContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getQualityLabelContainer()->getFactory()->create();
}

public function configureFields(string $pageName): iterable
{
return [
TextField::new('title'),
ImageManagerField::new('image'),
TextField::new('devAlias'),
];
}

}

+ 22
- 0
Controller/Reduction/ReductionCartAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Reduction;

use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\CaracoleBundle\Controller\AbstractAdminController;

abstract class ReductionCartAdminController extends AbstractAdminController
{

public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->getReductionCartContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getReductionCartContainer()->getFactory()->create($this->getSectionCurrent());
}

}

+ 19
- 0
Controller/Reduction/ReductionCatalogAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Reduction;

use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class ReductionCatalogAdminController extends AbstractAdminController
{
public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getReductionCatalogContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getReductionCatalogContainer()->getFactory()->create($this->getSectionCurrent());
}
}

+ 20
- 0
Controller/Reduction/ReductionCreditAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Reduction;

use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class ReductionCreditAdminController extends AbstractAdminController
{
public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(ReductionCreditContainer::class)->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getReductionCreditContainer()->getFactory()->create($this->getSectionCurrent());
}
}

+ 22
- 0
Controller/Reminder/ReminderAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Reminder;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\Reminder\ReminderAdminController as SovReminderAdminController;

class ReminderAdminController extends SovReminderAdminController
{
use AdminControllerTrait;

public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null)
{
return $this->getReminderContainer()
->getFactory()
->setMerchant($this->get(MerchantResolver::class)->getCurrent())
->setSection($this->get(SectionResolver::class)->getCurrent())
->create($crudAction, $crudControllerFqcn, $entityId);
}
}

+ 77
- 0
Controller/Section/OpeningAdminController.php Просмотреть файл

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

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;
use Lc\CaracoleBundle\Container\Section\OpeningContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Factory\Section\OpeningFactory;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

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 [
ChoiceField::new('day')
->setRequired(true)
->setChoices(
[
'Lundi' => 1,
'Mardi' => 2,
'Mercredi' => 3,
'Jeudi' => 4,
'Vendredi' => 5,
'Samedi' => 6,
'Dimanche' => 7,
]
),
TimeField::new('timeStart')
->setRequired(false)
->setFormat('H:mm'),
TimeField::new('timeEnd')
->setRequired(false)
->setFormat('H:mm'),
AssociationField::new('groupUser'),
];
}

public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{
$responseParameters = parent::configureResponseParameters($responseParameters);

$this->configureResponseParametersFilterSection($responseParameters);
$this->configureResponseParametersDisableShowAllSections($responseParameters);

return $responseParameters;
}
}

+ 64
- 0
Controller/Section/SectionAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Section;

use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Section\SectionContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Model\Section\SectionModel;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class SectionAdminController extends AbstractAdminController
{
public function getRepositoryQuery() :RepositoryQueryInterface
{
return $this->get(SectionContainer::class)->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getSectionContainer()
->getFactory()
->create($this->getMerchantCurrent());
}

public function configureFields(string $pageName): iterable
{
return array_merge(
[
FormField::addPanel('general'),
TextField::new('title'),
ChoiceField::new('cycleType')
->setRequired(true)
->hideOnIndex()
->setChoices(
[
'Jour' => SectionModel::CYCLE_TYPE_DAY,
'Semaine' => SectionModel::CYCLE_TYPE_WEEK,
'Mois' => SectionModel::CYCLE_TYPE_MONTH,
'Année' => SectionModel::CYCLE_TYPE_YEAR,
]
),
TextField::new('color')
->setRequired(true),
NumberField::new('position')
->hideOnForm()
->hideOnIndex(),
CKEditorField::new('description')
->hideOnIndex(),
BooleanField::new('isDefault'),
StatusField::new('status'),
],
$this->getSeoPanel(),
$this->getConfPanel(),
);
}

}

+ 50
- 0
Controller/Section/SwitchSectionAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Section;

use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Builder\User\UserMerchantBuilder;
use Lc\CaracoleBundle\Container\Section\SectionContainer;
use Lc\CaracoleBundle\Form\Section\SwitchSectionFormType;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class SwitchSectionAdminController extends AbstractController
{
/**
* @Route("/admin/section/switch", name="carac_section_switch")
*/
public function switchSection(
Request $request,
EntityManagerInterface $entityManager,
MerchantResolver $merchantResolver,
SectionContainer $sectionContainer,
UserMerchantBuilder $userMerchantBuilder
) {
$form = $this->createForm(SwitchSectionFormType::class);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

// valeur par défaut de $section : Tout afficher
$section = null;
$idSection = $form->get('id_section')->getData();
$userMerchant = $merchantResolver->getUserMerchant();

if($userMerchant) {
if($idSection) {
$section = $sectionContainer->getStore()->getOneById($idSection);
}

$userMerchant->setCurrentAdminSection($section);
$entityManager->update($userMerchant);
$entityManager->flush();
}
}

$referer = $request->headers->get('referer');
return $this->redirect($referer);
}
}

+ 113
- 0
Controller/Setting/SettingAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Setting;

use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Controller\Setting\SettingAdminController as SovSettingController;
use Lc\CaracoleBundle\Form\Setting\MerchantSettingsFormType;
use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType;
use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class SettingAdminController extends SovSettingController
{
use ControllerTrait;

/**
* @Route("/admin/setting/merchant", name="carac_admin_setting_merchant")
*/
public function manageMerchant(Request $request)
{
return $this->manage($request, 'merchant');
}

/**
* @Route("/admin/setting/section", name="carac_admin_setting_section")
*/
public function manageSection(Request $request)
{
return $this->manage($request, 'section');
}

public function manage(
Request $request,
$type
) {
$entity = null;
$entityManager = $this->getEntityManager();

if ($type == 'merchant') {
$resolver = $this->getMerchantContainer()->getResolver();
$formClass = MerchantSettingsFormType::class;
$settingDefinition = $this->getMerchantSettingContainer()->getDefinition();
} elseif ($type == 'section') {
$resolver = $this->getSectionContainer()->getResolver();
$formClass = SectionSettingsFormType::class;
$settingDefinition = $this->getSectionSettingContainer()->getDefinition();
}

$entity = $resolver->getCurrent();
$displaySwitchSection = ($type == 'section') ? true : false;
$view = '@LcCaracole/admin/setting/edit_' . $type . '.html.twig';

if ($entity) {
$form = $this->createForm($formClass, $entity);

$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$entityManager->update($entity);
$entityManager->flush();

$this->addFlashTranslator('success', 'updated');
}

return $this->render(
$view,
[
'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."
]
);
}
}

/**
* @Route("/admin/setting/site2", name="carac_admin_setting_site")
*/
public function manageGlobal(Request $request)
{
$entityManager = $this->getEntityManager();
$site = $this->getSiteContainer()->getStore()->getOneByDevAlias('default');
$form = $this->createForm(SiteSettingsFormType::class, $site);

$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$entityManager->update($site);
$entityManager->flush();

$this->addFlashTranslator('success', 'updated');
}

return $this->render(
'@LcCaracole/admin/setting/edit_site.html.twig',
[
'setting_definition' => $this->getSiteSettingContainer()->getDefinition(),
'form' => $form->createView()
]
);
}
}

+ 19
- 0
Controller/Site/NewsAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Site;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController;

abstract class NewsAdminController extends SovNewsAdminController
{
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->getNewsContainer()
->getFactory()
->setSection($this->getSectionCurrent())
->create();
}
}

+ 20
- 0
Controller/Site/PageAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Site;

use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController;

abstract class PageAdminController extends SovPageAdminController
{
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->getPageContainer()
->getFactory()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->create();
}
}

+ 45
- 0
Controller/Ticket/TicketAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\Ticket;

use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Definition\ActionDefinition;
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController;

abstract class TicketAdminController extends SovTicketAdminController
{
use AdminControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->getTicketContainer()
->getFactory()
->setSection($this->getSectionCurrent())
->setMerchant($this->getMerchantCurrent())
->create();
}

public function configureFields(string $pageName): iterable
{
return $this->getTicketContainer()->getFieldDefinition()
->setMerchant($this->getMerchantCurrent())
->setSection($this->getSectionCurrent())
->getFields($pageName);
}

public function configureActions(Actions $actions): Actions
{
$actions = parent::configureActions($actions);

if(!$this->getSectionCurrent()) {
$actions->disable(ActionDefinition::NEW, ActionDefinition::EDIT, ActionDefinition::DUPLICATE,ActionDefinition::DUPLICATE_TO_OTHER_SECTION, ActionDefinition::DELETE);
}else{
$actions->disable( ActionDefinition::EDIT, ActionDefinition::DUPLICATE,ActionDefinition::DUPLICATE_TO_OTHER_SECTION, ActionDefinition::DELETE);
}

return $actions;
}

}

+ 19
- 0
Controller/User/GroupUserAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\User;

use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController;

abstract class GroupUserAdminController extends SovGroupUserAdminController
{
use ControllerTrait;

public function createEntity(string $entityFqcn)
{
return $this->getGroupUserContainer()
->getFactory()
->setMerchant($this->getMerchantCurrent())
->create();
}
}

+ 0
- 64
Controller/User/GroupUserCrudController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\User;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

abstract class GroupUserCrudController extends AbstractCrudController
{


public function configureCrud(Crud $crud): Crud
{
return $crud
->setSearchFields(['id', 'title', 'description', 'devAlias', 'position', 'status', 'slug', 'image', 'metaTitle', 'metaDescription', 'oldUrls'])
->setPaginatorPageSize(50)
->setEntityPermission('ROLE_ADMIN')
->overrideTemplate('layout', '@LcCaracole/backend/default/layout/layout.html.twig')
->overrideTemplate('main_menu', '@LcCaracole/backend/default/menu.html.twig')
->overrideTemplate('crud/edit', '@LcCaracole/backend/default/edit.html.twig')
->overrideTemplate('crud/index', '@LcCaracole/backend/default/list.html.twig')
->overrideTemplate('crud/new', '@LcCaracole/backend/default/new.html.twig')
->overrideTemplate('crud/paginator', '@LcCaracole/backend/default/block/paginator.html.twig');
}

public function configureFields(string $pageName): iterable
{
$title = TextField::new('title');
$devAlias = TextField::new('devAlias');
$id = IntegerField::new('id', 'ID');
$description = TextareaField::new('description');
$createdAt = DateTimeField::new('createdAt');
$updatedAt = DateTimeField::new('updatedAt');
$position = NumberField::new('position');
$status = Field::new('status')->setTemplatePath('@LcShop/backend/default/field/toggle.html.twig');
$slug = TextField::new('slug');
$image = TextField::new('image');
$metaTitle = TextField::new('metaTitle');
$metaDescription = TextareaField::new('metaDescription');
$oldUrls = ArrayField::new('oldUrls');
$merchant = AssociationField::new('merchant');
$users = AssociationField::new('users');
$createdBy = AssociationField::new('createdBy');
$updatedBy = AssociationField::new('updatedBy');

if (Crud::PAGE_INDEX === $pageName) {
return [$title, $status];
} elseif (Crud::PAGE_DETAIL === $pageName) {
return [$id, $title, $description, $devAlias, $createdAt, $updatedAt, $position, $status, $slug, $image, $metaTitle, $metaDescription, $oldUrls, $merchant, $users, $createdBy, $updatedBy];
} elseif (Crud::PAGE_NEW === $pageName) {
return [$title, $devAlias];
} elseif (Crud::PAGE_EDIT === $pageName) {
return [$title, $devAlias];
}
}
}

+ 46
- 0
Controller/User/UserAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\User;


use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Lc\CaracoleBundle\Controller\ControllerTrait;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Controller\User\UserAdminController as SovUserAdminController;
use Lc\SovBundle\Definition\ActionDefinition;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

abstract class UserAdminController extends SovUserAdminController
{
use ControllerTrait;

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getUserContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getUserContainer()->getFactory()->create();
}

public function overrideEntitiesActions(?EntityCollection $entities): void
{
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action){
if($action->getName() == ActionDefinition::SWITCH_USER){
$sectionDefault = $this->getSectionContainer()->getStore()->setMerchant($this->getMerchantCurrent())->getOneDefault();

$url = $this->generateUrl($this->getParameter('lc_sov.homepage_route'), array('_switch_user' => $entity->getInstance()->getEmail(), 'section'=> $sectionDefault->getSlug()));
$action->setLinkUrl($url);
}
}

}
}




}

+ 236
- 0
Controller/User/UserMerchantAdminController.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Controller\User;

use App\Controller\Credit\CreditHistoryAdminController;
use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Lc\CaracoleBundle\Container\User\UserMerchantContainer;
use Lc\CaracoleBundle\Controller\AbstractAdminController;
use Lc\CaracoleBundle\Definition\ActionDefinition;
use Lc\CaracoleBundle\Form\User\UserMerchantActiveCreditFormType;
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\HttpFoundation\Response;

abstract class UserMerchantAdminController extends AbstractAdminController
{


public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getUserMerchantContainer()->getRepositoryQuery();
}

public function createEntity(string $entityFqcn)
{
return $this->getUserMerchantContainer()->getFactory()->createBase($this->getMerchantCurrent());
}

public function createIndexRepositoryQuery(
SearchDto $searchDto,
EntityDto $entityDto,
FieldCollection $fields,
FilterCollection $filters
): RepositoryQueryInterface {
$repositoryQuery = parent::createIndexRepositoryQuery($searchDto, $entityDto, $fields, $filters);
$repositoryQuery->filterIsCreditActive();
return $repositoryQuery;
}

public function overrideEntitiesActions(?EntityCollection $entities): void
{
$context = $this->get(AdminContextProvider::class)->getContext();
$adminUrlGenerator = $this->get(AdminUrlGenerator::class);

$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn(
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class)
);

if ($entities) {
foreach ($entities as $entity) {
foreach ($entity->getActions() as $action) {
if ($action->getName() == 'credit_history') {
$url = $adminUrlGenerator
->setController($creditControllerFqcn)
->set('userMerchantId', $entity->getInstance()->getId())
->generateUrl();
$action->setLinkUrl($url);
}
}
}
}
}

public function configureActions(Actions $actions): Actions
{
$actions = parent::configureActions($actions);

$creditAction = Action::new('credit_history', false, 'fa fa-cash-register')
->linkToCrudAction('credit_history')
->setHtmlAttributes(
array(
'data-toggle' => 'tooltip',
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'),
)
)
->setCssClass('btn btn-sm btn-success');
$actions->add(Crud::PAGE_INDEX, $creditAction);
$actions->disable(
ActionDefinition::EDIT,
ActionDefinition::DUPLICATE,
ActionDefinition::DELETE,
ActionDefinition::DUPLICATE_TO_OTHER_MERCHANT
);

return $actions;
}

public function configureFields(string $pageName): iterable
{
return $this->getUserMerchantContainer()->getFieldDefinition()->getFields($pageName);
}

public function configureFilters(Filters $filters): Filters
{
return $filters
->add(BooleanFilter::new('active'));
}

public function new(AdminContext $context): Response
{
$entityManager = $this->get(EntityManagerInterface::class);
$merchantResolver = $this->get(MerchantResolver::class);

$userMerchant = $this->get(UserMerchantContainer::class)
->getFactory()
->create($merchantResolver->getCurrent());

$form = $this->createForm(
UserMerchantActiveCreditFormType::class,
$userMerchant,
array(
'merchant' => $this->getMerchantCurrent()
)
);

$form->handleRequest($context->getRequest());

if ($form->isSubmitted() && $form->isValid()) {

$user = $form->get('user')->getData();
$userMerchant = $merchantResolver->getUserMerchant($user);
$userMerchant->setCreditActive(true);
$entityManager->update($userMerchant);
$entityManager->flush();

$this->addFlashTranslator('success', 'creditActive');

return $this->redirect($this->generateEaUrl(CreditHistoryAdminController::class, ActionDefinition::INDEX, null, array(
'userMerchantId'=> $userMerchant->getId()
)));
}

return $this->render(
'@LcCaracole/admin/user/new_usermerchant.html.twig',
[
'form' => $form->createView(),
]
);
}


// public function edit(AdminContext $context): Response
// {
// $entityManager = $this->get(EntityManagerInterface::class);
//
// $userMerchant = $context->getEntity()->getInstance();
//
// $form = $this->createForm(UserMerchantFormType::class, $userMerchant);
//
// $form->handleRequest($context->getRequest());
//
// if ($form->isSubmitted() && $form->isValid()) {
// $userMerchant = $form->getData();
//
// $userMerchant->getUser()->setEmail($form->get('email')->getData());
// $userMerchant->getUser()->setLastName($form->get('lastname')->getData());
// $userMerchant->getUser()->setFirstname($form->get('firstname')->getData());
//
// $entityManager->update($userMerchant);
// $entityManager->update($userMerchant->getUser());
// $entityManager->flush();
// $this->addFlashTranslator('success', 'updated');
// $url = $this->get(AdminUrlGenerator::class)->setAction(ActionDefinition::INDEX)->generateUrl();
//
// return $this->redirect($url);
// } else {
// $form->get('email')->setData($userMerchant->getUser()->getEmail());
// $form->get('lastname')->setData($userMerchant->getUser()->getLastname());
// $form->get('firstname')->setData($userMerchant->getUser()->getFirstname());
// }
//
// return $this->render(
// '@LcCaracole/admin/user/edit_usermerchant.html.twig',
// [
// 'form' => $form->createView(),
// ]
// );
// }

// public function credit(AdminContext $context, AdminUrlGenerator $adminUrlGenerator): Response
// {
// $event = new BeforeCrudActionEvent($context);
// $this->get('event_dispatcher')->dispatch($event);
// if ($event->isPropagationStopped()) {
// return $event->getResponse();
// }
//
// if (!$this->isGranted(
// Permission::EA_EXECUTE_ACTION,
// ['action' => ActionDefinition::DETAIL, 'entity' => $context->getEntity()]
// )) {
// throw new ForbiddenActionException($context);
// }
// if (!$context->getEntity()->isAccessible()) {
// throw new InsufficientEntityPermissionException($context);
// }
//
// $options['action'] = $adminUrlGenerator
// ->setController($context->getCrud()->getControllerFqcn())
// ->setAction('add_credit')
// ->setEntityId($context->getEntity()->getInstance()->getId())
// ->set('userMerchant', 'niche')
// ->generateUrl();
// $addCreditHistoryForm = $this->createForm(CreditHistoryFormType::class, null, $options)->createView();
//
//
// return $this->render(
// '@LcCaracole/admin/credit/credit_detail.html.twig',
// [
// 'pageName' => Crud::PAGE_DETAIL,
// 'entity' => $context->getEntity(),
// 'batch_actions' => array(),
// 'entities' => array(),
// 'filters' => array(),
// 'paginator' => array(),
// 'add_credit_history_form' => $addCreditHistoryForm,
// ]
// );
// }

}

+ 129
- 0
Definition/AbstractSettingDefinition.php Просмотреть файл

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


namespace Lc\CaracoleBundle\Definition;


abstract class AbstractSettingDefinition
{
protected $settings = [];

public function addSettingText(array $params): self
{
$params['type'] = 'text';
$params['field'] = 'text';
return $this->addSetting($params);
}

public function addSettingTextarea(array $params): self
{
$params['type'] = 'textarea';
$params['field'] = 'text';
return $this->addSetting($params);
}

public function addSettingTextareaAdvanced(array $params): self
{
$params['type'] = 'textarea_advanced';
$params['field'] = 'text';
return $this->addSetting($params);
}

public function addSettingDate(array $params): self
{
$params['type'] = 'date';
$params['field'] = 'date';
return $this->addSetting($params);
}

public function addSettingTime(array $params): self
{
$params['type'] = 'time';
$params['field'] = 'date';
return $this->addSetting($params);
}

public function addSettingFile(array $params): self
{
$params['type'] = 'file';
$params['field'] = 'file';
return $this->addSetting($params);
}

public function addSettingImage(array $params): self
{
$params['type'] = 'image';
$params['field'] = 'file';
return $this->addSetting($params);
}

public function addSettingSelect(array $params): self
{
$params['type'] = 'select';
$params['field'] = 'text';
return $this->addSetting($params);
}

public function addSettingRadio(array $params): self
{
$params['type'] = 'radio';
$params['field'] = 'text';
return $this->addSetting($params);
}

public function addSetting($params)
{
$name = $params['name'];
$category = $params['category'];

if (!isset($this->settings[$category])) {
$this->settings[$category] = [];
}

$this->settings[$category][$name] = $params;

return $this;
}

public function getSettings(): array
{
return $this->settings;
}

public function getSettingsByCategory($category)
{
$settings = $this->getSettings();

if (isset($settings[$category])) {
return $settings[$category];
}

return [];
}

public function getSettingByName($name): ?array
{
$settings = $this->getSettings();

foreach ($settings as $category => $settingsCategory) {
foreach ($settingsCategory as $nameSetting => $setting) {
if ($nameSetting == $name) {
return $setting;
}
}
}

return null;
}

public function getSettingType($name): ?string
{
$setting = $this->getSettingByName($name);

if ($setting) {
return $setting['type'];
}

return null;
}
}

+ 13
- 0
Definition/ActionDefinition.php Просмотреть файл

@@ -0,0 +1,13 @@
<?php
namespace Lc\CaracoleBundle\Definition;

use Lc\SovBundle\Definition\ActionDefinition as SovActionDefinition;

class ActionDefinition extends SovActionDefinition{

public const DUPLICATE_TO_OTHER_MERCHANT = 'duplicateToOtherMerchant';
public const DUPLICATE_TO_OTHER_SECTION = 'duplicateToOtherSection';
public const EDIT_ADDRESS_USER = 'editAddressUser';


}

+ 10
- 0
Definition/Field/AbstractFieldDefinition.php Просмотреть файл

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

+ 80
- 0
Definition/Field/Credit/CreditHistoryFieldDefinition.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Definition\Field\Credit;

use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Solver\Credit\CreditHistorySolver;
use Lc\CaracoleBundle\Solver\Order\OrderPaymentSolver;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;

class CreditHistoryFieldDefinition extends AbstractFieldDefinition
{
use MerchantContextTrait;

public function configureIndex(): array
{
return [
'id',
'type',
'amount',
'paidAt',
'meanPayment',
'reference',
'comment',
];
}

public function configureForm(): array
{
return [
'type',
'amount',
'paidAt',
'meanPayment',
'reference',
'comment',
];
}

public function configureFields(): array
{
return [
'id' => IdField::new('id')->hideOnForm(),
'type' => ChoiceField::new('type')
->setChoices(
$this->translatorAdmin->transChoices(
CreditHistorySolver::getTypeChoices(),
'CreditHistory',
'type'
)
),
'amount' => NumberField::new('amount')
->setTemplatePath('@LcCaracole/admin/credit/field/amount.html.twig')
->setCustomOption('appendHtml', '&euro;'),
'paidAt' => DateField::new('paidAt')->setFormTypeOption('required', true)
->setTemplatePath('@LcCaracole/admin/credit/field/paidAt.html.twig'),
'meanPayment' => ChoiceField::new('meanPayment')
->setChoices(
$this->translatorAdmin->transChoices(
OrderPaymentSolver::getMeanPaymentChoices(),
'OrderPayment',
'meanPayment'
)
)->setFormTypeOption('required', true)
->setTemplatePath('@LcCaracole/admin/credit/field/meanPayment.html.twig'),
'reference' => TextField::new('reference')
->setTemplatePath('@LcCaracole/admin/credit/field/reference.html.twig'),
'comment' => TextField::new('comment')
->setTemplatePath('@LcCaracole/admin/credit/field/comment.html.twig'),

];
}

}



+ 46
- 0
Definition/Field/FieldDefinitionTrait.php Просмотреть файл

@@ -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 Просмотреть файл

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

+ 89
- 0
Definition/Field/Order/OrderShopFieldDefinition.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Definition\Field\Order;

use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
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\CaracoleBundle\Field\Filter\Order\OrderShopComplementaryFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopOrderDeliveryTypeFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopOrderPaymentFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopOrderStatusFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserEmailFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserFirstnameFilter;
use Lc\CaracoleBundle\Field\Filter\Order\OrderShopUserLastnameFilter;
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'];
}

public function configurePanels(): array
{
return [];
}

public function configureFields(): array
{
return [
'id' => IntegerField::new('id', 'ID')->setSortable(true),
'userLastname' => TextareaField::new('user.lastname')->setSortable(true)
->setCustomOption('filter_fqcn', OrderShopUserLastnameFilter::class),
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'),
'userFirstname' => TextareaField::new('user.firstname')->setSortable(true)
->setCustomOption('filter_fqcn', OrderShopUserFirstnameFilter::class),
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'),
'userEmail' => TextareaField::new('user.email')->setSortable(true)
->setCustomOption('filter_fqcn', OrderShopUserEmailFilter::class),
//->setTemplatePath('@LcShop/backend/default/field/user.html.twig'),
'total' => NumberField::new('total')
->setTemplatePath('@LcCaracole/admin/order/field/total.html.twig'),
'orderStatus' => AssociationField::new('orderStatus')->setSortable(true)
->setTemplatePath('@LcCaracole/admin/order/field/order_status.html.twig')
->setCustomOption('filter_fqcn', OrderShopOrderStatusFilter::class),
'createdAt' => DateTimeField::new('createdAt')->setSortable(true),
'updatedAt' => DateTimeField::new('updatedAt')->setSortable(true),
'orderShopCreatedAt' => DateTimeField::new('orderShopCreatedAt')->setSortable(true),
'distribution' => AssociationField::new('distribution')
->setSortable(true)
->setCustomOption('filter_type', TextType::class)
->setCustomOption('filter_on', 'cycleNumber'),
'cycleDeliveryId' => IntegerField::new('cycleDeliveryId')->setSortable(true),
'cycleId' => IntegerField::new('cycleId')->setSortable(true),
'deliveryType' => Field::new('deliveryType')->setSortable(true)
->setCustomOption('filter_fqcn', OrderShopOrderDeliveryTypeFilter::class),
//->setTemplatePath('@LcShop/backend/default/field/options_translatable.html.twig'),
'reference' => TextField::new('reference')->setSortable(true),
'complementaryOrderShops' => AssociationField::new('complementaryOrderShops')
->setFormTypeOption('mapped', false)
->setCustomOption('filter', false)
->setTemplatePath('@LcCaracole/admin/order/field/complementary.html.twig'),
'orderPayments' => AssociationField::new('orderPayments')
->setTemplatePath('@LcCaracole/admin/order/field/order_payment.html.twig')
->setCustomOption('filter_fqcn', OrderShopOrderPaymentFilter::class),
'user' => AssociationField::new('user')->setSortable(true)
];
}

}

+ 65
- 0
Definition/Field/PointSale/PointSaleFieldDefinition.php Просмотреть файл

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

namespace Lc\CaracoleBundle\Definition\Field\PointSale;

use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\ImageManagerField;
use Lc\SovBundle\Field\StatusField;

class PointSaleFieldDefinition extends AbstractFieldDefinition
{

public function configureIndex(): array
{
return [
'id',
'title',
'status'
];
}

public function configurePanels(): array
{
return [
'main',
'address',
'seo',
'conf',
];
}

public function configurePanelMain(): array
{
return [
'title',
'description',
'status'
];
}

public function configurePanelAddress(): array
{
return [
'address'
];
}

public function configureFields(): array
{
return [
'id' => IntegerField::new('id')->setSortable(true)->onlyOnIndex(),
'title' => TextField::new('title')->setSortable(true),
'code' => TextField::new('code'),
'image' => ImageManagerField::new('image'),
'description' => CKEditorField::new('description'),
'status' => StatusField::new('status')->setSortable(true),
'address' => AddressField::new('address')
->setRequired(true),
];
}

}

+ 86
- 0
Definition/Field/Product/ProductCategoryFieldDefinition.php Просмотреть файл

@@ -0,0 +1,86 @@
<?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\ImageManagerField;
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',
'position',
'createdAt',
'updatedAt',
'status',
'saleStatus',
'isEligibleTicketRestaurant'
]);
}

public function configurePanels(): array
{
return [
'main',
'seo',
'conf'
];
}

public function configurePanelMain(): array
{
return [
'section',
'parent',
'title',
'description',
'image',
'saleStatus',
'isEligibleTicketRestaurant',
];
}

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),
'image' => ImageManagerField::new('image'),
'description' => CKEditorField::new('description'),
'saleStatus' => ToggleField::new('saleStatus')->setSortable(true),
'isEligibleTicketRestaurant' => ToggleField::new('isEligibleTicketRestaurant')->setSortable(true),
];
}
}

+ 27
- 0
Definition/Field/Reduction/ReductionCartFieldDefinition.php Просмотреть файл

@@ -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 Просмотреть файл

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

Некоторые файлы не были показаны из-за большого количества измененных файлов

Загрузка…
Отмена
Сохранить