Kaynağa Gözat

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

packProduct
Fab 2 yıl önce
ebeveyn
işleme
2bfcc8fa32
5 değiştirilmiş dosya ile 88 ekleme ve 39 silme
  1. +1
    -1
      Controller/ControllerTrait.php
  2. +1
    -1
      Model/Newsletter/NewsletterModel.php
  3. +33
    -32
      Resolver/SectionResolver.php
  4. +5
    -5
      Solver/Order/OrderShopSolver.php
  5. +48
    -0
      Twig/StoreTwigExtension.php

+ 1
- 1
Controller/ControllerTrait.php Dosyayı Görüntüle

@@ -156,7 +156,7 @@ trait ControllerTrait

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

public function getSectionCurrentSlug(): string

+ 1
- 1
Model/Newsletter/NewsletterModel.php Dosyayı Görüntüle

@@ -17,7 +17,7 @@ abstract class NewsletterModel extends SovNewsletterModel implements FilterSecti
*/
protected $section;

public function getSection(): ?SectionInterface
public function getSection(): SectionInterface
{
return $this->section;
}

+ 33
- 32
Resolver/SectionResolver.php Dosyayı Görüntüle

@@ -19,33 +19,34 @@ class SectionResolver
protected ?SectionInterface $section = null;

protected EntityManagerInterface $entityManager;
protected Security $security;
protected MerchantResolver $merchantResolver;
protected SectionStore $sectionStore;
protected RequestStack $requestStack;
protected UrlResolver $urlResolver;

public function __construct(
EntityManagerInterface $entityManager,
MerchantResolver $merchantResolver,
SectionStore $sectionStore,
RequestStack $requestStack,
UrlResolver $urlResolver
)
{
EntityManagerInterface $entityManager,
Security $security,
MerchantResolver $merchantResolver,
SectionStore $sectionStore,
RequestStack $requestStack,
UrlResolver $urlResolver
) {
$this->entityManager = $entityManager;
$this->security = $security;
$this->merchantResolver = $merchantResolver;
$this->sectionStore = $sectionStore;
$this->requestStack = $requestStack;
$this->urlResolver = $urlResolver;
}

public function getCurrent()
public function getCurrent($returnDefaultIfOutOfSections = false, $returnVisitedIfOutOfSection = false)
{
$requestAttributesArray = $this->requestStack->getMainRequest()->attributes->all();

// admin
if (isset($requestAttributesArray['_firewall_context']) && $requestAttributesArray['_firewall_context'] == 'security.firewall.map.context.admin') {
//dump($requestAttributesArray);
if (!$this->isCachedSection) {
$currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant();
@@ -54,42 +55,42 @@ class SectionResolver
$currentAdminSection = $userMerchant->getCurrentAdminSection();
}

/*if ($currentAdminSection === null) {
$currentAdminSection = $this->sectionStore
->setMerchant($userMerchant->getMerchant())
->getOneDefault();

if ($currentAdminSection === null) {
throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
}
}*/

$this->isCachedSection = true;
$this->section = $currentAdminSection;

return $currentAdminSection;
}else{
} else {
return $this->section;
}
} // front
else {
$userCurrent = $this->security->getUser();
$merchantCurrent = $this->merchantResolver->getCurrent();
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent);

if($this->section === null) {
$merchantCurrent = $this->merchantResolver->getCurrent();
$sectionStore = $this->sectionStore->setMerchant($merchantCurrent);
$sectionCurrent = null;
$sectionDefault = $sectionStore->getOneDefault();
$sectionCurrent = null;
$sectionDefault = $sectionStore->getOneDefault();

if (isset($requestAttributesArray['section'])) {
$sectionCurrent = $sectionStore
->setMerchant($merchantCurrent)
->getOneBySlug($requestAttributesArray['section']);
}
$currentVisitedSection = null;
if ($userCurrent && $userCurrent->getCurrentVisitedSection()) {
$currentVisitedSection = $userCurrent->getCurrentVisitedSection();
}

if (isset($requestAttributesArray['section'])) {
$sectionCurrent = $sectionStore
->setMerchant($merchantCurrent)
->getOneBySlug($requestAttributesArray['section']);
}

$this->section = $sectionCurrent ?: $sectionDefault;
if ($sectionCurrent) {
return $sectionCurrent;
} elseif ($returnVisitedIfOutOfSection && $currentVisitedSection) {
return $currentVisitedSection;
} elseif ($returnDefaultIfOutOfSections && $sectionDefault) {
return $sectionDefault;
}

return $this->section;
return null;
}
}


+ 5
- 5
Solver/Order/OrderShopSolver.php Dosyayı Görüntüle

@@ -351,11 +351,11 @@ class OrderShopSolver
$byWeight = true;
}

return $this->productSolver->getAvailableQuantityInherited($product) - $this->getQuantityOrderByProduct(
$orderShop,
$product,
$byWeight
);
return max($this->productSolver->getAvailableQuantityInherited($product) - $this->getQuantityOrderByProduct(
$orderShop,
$product,
$byWeight
), 0);
}

public function hasMakeAChoiceAboutComplementaryOrder(OrderShop $orderShop): bool

+ 48
- 0
Twig/StoreTwigExtension.php Dosyayı Görüntüle

@@ -82,18 +82,36 @@ class StoreTwigExtension extends AbstractExtension

new TwigFunction('product_categories', [$this, 'getProductCategories']),
new TwigFunction('cart_current', [$this, 'getCartCurrent']),
new TwigFunction('cart_current_visited', [$this, 'getCartCurrentVisited']),
new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']),
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']),
new TwigFunction('section_current', [$this, 'getSectionCurrent']),
new TwigFunction('section_current_default', [$this, 'getSectionCurrentDefault']),
new TwigFunction('section_current_visited', [$this, 'getSectionCurrentVisited']),
new TwigFunction('is_out_of_sections', [$this, 'isOutOfSections']),
new TwigFunction('is_inside_section', [$this, 'isInsideSection']),
new TwigFunction('section_current_slug', [$this, 'getSectionCurrentSlug']),
new TwigFunction('section_current_default_slug', [$this, 'getSectionCurrentDefaultSlug']),
new TwigFunction('section_current_visited_slug', [$this, 'getSectionCurrentVisitedSlug']),
new TwigFunction('merchant_setting', [$this, 'getMerchantSetting']),
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']),
new TwigFunction('section_setting', [$this, 'getSectionSetting']),
new TwigFunction('section_setting_current', [$this, 'getSectionSettingCurrent']),
new TwigFunction('visitor_current', [$this, 'getVisitorCurrent']),

);
}

public function isInsideSection(): bool
{
return (bool) $this->sectionResolver->getCurrent();
}

public function isOutOfSections()
{
return $this->sectionResolver->isOutOfSection();
}

public function getSections()
{
return $this->sectionStore
@@ -111,11 +129,31 @@ class StoreTwigExtension extends AbstractExtension
return $this->sectionResolver->getCurrent();
}

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

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

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

public function getSectionCurrentDefaultSlug(): string
{
return $this->sectionResolver->getCurrent(true)->getSlug();
}

public function getSectionCurrentVisitedSlug(): string
{
return $this->sectionResolver->getCurrent(true, true)->getSlug();
}

public function getCartCurrent(): OrderShopInterface
{
return $this->orderShopBuilder->createIfNotExist(
@@ -126,6 +164,16 @@ class StoreTwigExtension extends AbstractExtension
);
}

public function getCartCurrentVisited(): OrderShopInterface
{
return $this->orderShopBuilder->createIfNotExist(
$this->sectionResolver->getCurrent(true, true),
$this->security->getUser(),
$this->visitorResolver->getCurrent(),
true
);
}

public function getMerchantCurrent(): MerchantInterface
{
return $this->merchantResolver->getCurrent();

Yükleniyor…
İptal
Kaydet