Fabien Normand преди 3 години
родител
ревизия
f768d5702d
променени са 4 файла, в които са добавени 31 реда и са изтрити 8 реда
  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 Целия файл

@@ -145,7 +145,10 @@ class OrderShopBuilder

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

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


+ 3
- 4
Repository/Order/OrderShopRepositoryQuery.php Целия файл

@@ -186,9 +186,7 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery

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
@@ -262,7 +260,8 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
if (!$this->isJoinOrderProduct) {
$this->isJoinOrderProduct = true;

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

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

+ 7
- 3
Resolver/MerchantResolver.php Целия файл

@@ -17,6 +17,7 @@ use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\User\UserMerchantRepository;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Resolver\UrlResolver;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -34,6 +35,7 @@ class MerchantResolver
protected UrlGeneratorInterface $router;
protected MerchantStore $merchantStore;
protected ParameterBagInterface $parameterBag;
protected SettingSolver $settingSolver;

public function __construct(
EntityManagerInterface $entityManager,
@@ -44,7 +46,8 @@ class MerchantResolver
UserMerchantRepository $userMerchantRepository,
UrlGeneratorInterface $router,
MerchantStore $merchantStore,
ParameterBagInterface $parameterBag
ParameterBagInterface $parameterBag,
SettingSolver $settingSolver
) {
$this->requestStack = $requestStack;
$this->em = $entityManager;
@@ -55,6 +58,7 @@ class MerchantResolver
$this->merchantStore = $merchantStore;
$this->router = $router;
$this->parameterBag = $parameterBag;
$this->settingSolver = $settingSolver;
}

public function getCurrent(): MerchantInterface
@@ -78,7 +82,7 @@ class MerchantResolver
} // distant
else {
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) {
$this->currentMerchant = $merchant;
}
@@ -126,7 +130,7 @@ class MerchantResolver
if ($this->urlResolver->isServerLocalhost()) {
return $this->router->generate('frontend_home', ['section' => $section->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
} else {
return $section->getMerchant()->getSettingValue(MerchantSettingDefinition::SETTING_URL);
return $this->settingSolver->getSettingValue($section->getMerchant(), MerchantSettingDefinition::SETTING_URL);
}
}


+ 17
- 0
Resolver/SectionResolver.php Целия файл

@@ -18,6 +18,11 @@ class SectionResolver
protected bool $isCachedSection = false;
protected ?SectionInterface $section = null;

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

protected EntityManagerInterface $entityManager;
protected Security $security;
protected MerchantResolver $merchantResolver;
@@ -64,6 +69,15 @@ class SectionResolver
}
} // front
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();
$merchantCurrent = $this->merchantResolver->getCurrent();
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent);
@@ -83,10 +97,13 @@ class SectionResolver
}

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


Loading…
Отказ
Запис