Procházet zdrojové kódy

Modification SectionResolver et MerchantResolver

packProduct
Guillaume před 2 roky
rodič
revize
bc057c04e3
3 změnil soubory, kde provedl 15 přidání a 22 odebrání
  1. +4
    -3
      Resolver/MerchantResolver.php
  2. +5
    -19
      Resolver/SectionResolver.php
  3. +6
    -0
      Twig/StoreTwigExtension.php

+ 4
- 3
Resolver/MerchantResolver.php Zobrazit soubor

@@ -10,6 +10,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
@@ -119,12 +120,12 @@ class MerchantResolver
);
}

public function getUrl($merchant)
public function getUrl(SectionInterface $section)
{
if ($this->urlResolver->isServerLocalhost()) {
return $this->router->generate('frontend_home', [], UrlGeneratorInterface::ABSOLUTE_URL);
return $this->router->generate('frontend_home', ['section' => $section->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
} else {
return $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL);
return $section->getMerchant()->getSettingValue(MerchantSettingDefinition::SETTING_URL);
}
}


+ 5
- 19
Resolver/SectionResolver.php Zobrazit soubor

@@ -61,29 +61,15 @@ class SectionResolver
return $currentAdminSection;
} // front
else {
$sectionStore = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent());
$sectionCurrent = null;
$isCli = php_sapi_name() === 'cli';
$sectionDefault = $sectionStore->getOneDefault();

// local
if ($isCli || $this->urlResolver->isServerLocalhost()) {
$sectionArray = $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOnline();

foreach ($sectionArray as $section) {
if ($section->getDevAlias() == $_ENV['CURRENT_SECTION_LOCAL']) {
$sectionCurrent = $section;
}
}
}
// distant
else {
$sectionCurrent = $this->sectionStore
->setMerchant($this->merchantResolver->getCurrent())
->getOneDefault();
if(isset($requestAttributesArray['section'])) {
$sectionCurrent = $sectionStore->getOneBySlug($requestAttributesArray['section']);
}

return $sectionCurrent;
return $sectionCurrent ?: $sectionDefault;
}
}


+ 6
- 0
Twig/StoreTwigExtension.php Zobrazit soubor

@@ -85,6 +85,7 @@ class StoreTwigExtension extends AbstractExtension
new TwigFunction('merchant_current', [$this, 'getMerchantCurrent']),
new TwigFunction('user_merchant_current', [$this, 'getUserMerchantCurrent']),
new TwigFunction('section_current', [$this, 'getSectionCurrent']),
new TwigFunction('section_slug_current', [$this, 'getSectionSlugCurrent']),
new TwigFunction('merchant_setting', [$this, 'getMerchantSetting']),
new TwigFunction('merchant_setting_current', [$this, 'getMerchantSettingCurrent']),
new TwigFunction('section_setting', [$this, 'getSectionSetting']),
@@ -109,6 +110,11 @@ class StoreTwigExtension extends AbstractExtension
return $this->sectionResolver->getCurrent();
}

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

public function getCartCurrent(): OrderShopInterface
{
return $this->orderShopBuilder->createIfNotExist(

Načítá se…
Zrušit
Uložit