Bläddra i källkod

SectionResolver : système de cache

packProduct
Guillaume 2 år sedan
förälder
incheckning
445c6b93c5
3 ändrade filer med 24 tillägg och 5 borttagningar
  1. +4
    -1
      Builder/Order/OrderShopBuilder.php
  2. +3
    -4
      Repository/Order/OrderShopRepositoryQuery.php
  3. +17
    -0
      Resolver/SectionResolver.php

+ 4
- 1
Builder/Order/OrderShopBuilder.php Visa fil

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

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

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

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

+ 17
- 0
Resolver/SectionResolver.php Visa fil

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


Laddar…
Avbryt
Spara