Browse Source

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

packProduct
Fabien Normand 3 years ago
parent
commit
f768d5702d
4 changed files with 31 additions and 8 deletions
  1. +4
    -1
      Builder/Order/OrderShopBuilder.php
  2. +3
    -4
      Repository/Order/OrderShopRepositoryQuery.php
  3. +7
    -3
      Resolver/MerchantResolver.php
  4. +17
    -0
      Resolver/SectionResolver.php

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



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

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



+ 3
- 4
Repository/Order/OrderShopRepositoryQuery.php View File



public function filterByVisitor(VisitorInterface $visitor): self public function filterByVisitor(VisitorInterface $visitor): self
{ {
return $this
->andWhere('.visitor = :visitor')
->setParameter('visitor', $visitor);
return $this->andWhereEqual('visitor', $visitor);
} }


public function filterByAddress(AddressInterface $address): self public function filterByAddress(AddressInterface $address): self
if (!$this->isJoinOrderProduct) { if (!$this->isJoinOrderProduct) {
$this->isJoinOrderProduct = true; $this->isJoinOrderProduct = true;


$this->innerJoin('.orderProducts', 'orderProduct');
$this->leftJoin('.orderProducts', 'orderProduct');

if ($addSelect) { if ($addSelect) {
$this->addSelect('orderProduct'); $this->addSelect('orderProduct');
} }

+ 7
- 3
Resolver/MerchantResolver.php View File

use Lc\CaracoleBundle\Repository\User\UserMerchantRepository; use Lc\CaracoleBundle\Repository\User\UserMerchantRepository;
use Lc\SovBundle\Model\User\UserInterface; use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Resolver\UrlResolver; use Lc\SovBundle\Resolver\UrlResolver;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
protected UrlGeneratorInterface $router; protected UrlGeneratorInterface $router;
protected MerchantStore $merchantStore; protected MerchantStore $merchantStore;
protected ParameterBagInterface $parameterBag; protected ParameterBagInterface $parameterBag;
protected SettingSolver $settingSolver;


public function __construct( public function __construct(
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
UserMerchantRepository $userMerchantRepository, UserMerchantRepository $userMerchantRepository,
UrlGeneratorInterface $router, UrlGeneratorInterface $router,
MerchantStore $merchantStore, MerchantStore $merchantStore,
ParameterBagInterface $parameterBag
ParameterBagInterface $parameterBag,
SettingSolver $settingSolver
) { ) {
$this->requestStack = $requestStack; $this->requestStack = $requestStack;
$this->em = $entityManager; $this->em = $entityManager;
$this->merchantStore = $merchantStore; $this->merchantStore = $merchantStore;
$this->router = $router; $this->router = $router;
$this->parameterBag = $parameterBag; $this->parameterBag = $parameterBag;
$this->settingSolver = $settingSolver;
} }


public function getCurrent(): MerchantInterface public function getCurrent(): MerchantInterface
} // distant } // distant
else { else {
foreach ($merchants as $merchant) { foreach ($merchants as $merchant) {
$url = $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
$url = $this->settingSolver->getSettingValue($merchant, MerchantSettingDefinition::SETTING_URL);
if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) { if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) {
$this->currentMerchant = $merchant; $this->currentMerchant = $merchant;
} }
if ($this->urlResolver->isServerLocalhost()) { if ($this->urlResolver->isServerLocalhost()) {
return $this->router->generate('frontend_home', ['section' => $section->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL); return $this->router->generate('frontend_home', ['section' => $section->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
} else { } else {
return $section->getMerchant()->getSettingValue(MerchantSettingDefinition::SETTING_URL);
return $this->settingSolver->getSettingValue($section->getMerchant(), MerchantSettingDefinition::SETTING_URL);
} }
} }



+ 17
- 0
Resolver/SectionResolver.php View File

protected bool $isCachedSection = false; protected bool $isCachedSection = false;
protected ?SectionInterface $section = null; protected ?SectionInterface $section = null;


// cache front
protected ?SectionInterface $cacheSectionCurrent = null;
protected ?SectionInterface $cacheSectionVisited = null;
protected ?SectionInterface $cacheSectionDefault = null;

protected EntityManagerInterface $entityManager; protected EntityManagerInterface $entityManager;
protected Security $security; protected Security $security;
protected MerchantResolver $merchantResolver; protected MerchantResolver $merchantResolver;
} }
} // front } // front
else { else {

if ($this->cacheSectionCurrent) {
return $this->cacheSectionCurrent;
} elseif ($returnVisitedIfOutOfSection && $this->cacheSectionVisited) {
return $this->cacheSectionVisited;
} elseif ($returnDefaultIfOutOfSections && $this->cacheSectionDefault) {
return $this->cacheSectionDefault;
}

$userCurrent = $this->security->getUser(); $userCurrent = $this->security->getUser();
$merchantCurrent = $this->merchantResolver->getCurrent(); $merchantCurrent = $this->merchantResolver->getCurrent();
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent); $sectionStore = $this->sectionStore->setMerchant($merchantCurrent);
} }


if ($sectionCurrent) { if ($sectionCurrent) {
$this->cacheSectionCurrent = $sectionCurrent;
return $sectionCurrent; return $sectionCurrent;
} elseif ($returnVisitedIfOutOfSection && $currentVisitedSection) { } elseif ($returnVisitedIfOutOfSection && $currentVisitedSection) {
$this->cacheSectionVisited = $currentVisitedSection;
return $currentVisitedSection; return $currentVisitedSection;
} elseif ($returnDefaultIfOutOfSections && $sectionDefault) { } elseif ($returnDefaultIfOutOfSections && $sectionDefault) {
$this->cacheSectionDefault = $sectionDefault;
return $sectionDefault; return $sectionDefault;
} }



Loading…
Cancel
Save