瀏覽代碼

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

packProduct
Fabien Normand 3 年之前
父節點
當前提交
820268a084
共有 1 個文件被更改,包括 25 次插入15 次删除
  1. +25
    -15
      Resolver/MerchantResolver.php

+ 25
- 15
Resolver/MerchantResolver.php 查看文件

@@ -61,6 +61,11 @@ class MerchantResolver
$this->settingSolver = $settingSolver;
}

public function isOutOfMerchant()
{
return !$this->getCurrentProtected();
}

public function getCurrent(): MerchantInterface
{
if (isset($this->currentMerchant) && $this->currentMerchant) {
@@ -68,6 +73,23 @@ class MerchantResolver
}

$this->currentMerchant = null;
$merchant = $this->getCurrentProtected();

if($merchant) {
$this->currentMerchant = $merchant;
}

if ($this->currentMerchant instanceof MerchantInterface) {
return $this->currentMerchant;
}
else {
throw new \ErrorException('Aucun merchant courant');
}
}

protected function getCurrentProtected(): ?MerchantInterface
{
$currentMerchant = null;
$request = $this->requestStack->getCurrentRequest();
$merchants = $this->merchantRepository->findAll();
$isCli = php_sapi_name() === 'cli';
@@ -76,7 +98,7 @@ class MerchantResolver
if ($isCli || $this->urlResolver->isServerLocalhost()) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) {
$this->currentMerchant = $merchant;
$currentMerchant = $merchant;
}
}
} // distant
@@ -84,25 +106,13 @@ class MerchantResolver
foreach ($merchants as $merchant) {
$url = $this->settingSolver->getSettingValue($merchant, MerchantSettingDefinition::SETTING_URL);
if ($url && strlen($url) && strpos($url, $_SERVER['HTTP_HOST']) !== false) {
$this->currentMerchant = $merchant;
}
}
}
} else {
/*if ($_ENV['CURRENT_MERCHANT_COMMAND']) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_COMMAND']) {
$currentMerchant = $merchant;
}
}
}*/
}
}

if ($this->currentMerchant instanceof MerchantInterface) {
return $this->currentMerchant;
} else {
throw new \ErrorException('Aucun merchant courant');
}
return $currentMerchant;
}

public function getUserMerchant(

Loading…
取消
儲存