ソースを参照

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(

読み込み中…
キャンセル
保存