Parcourir la source

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

packProduct
Fabien Normand il y a 3 ans
Parent
révision
820268a084
1 fichiers modifiés avec 25 ajouts et 15 suppressions
  1. +25
    -15
      Resolver/MerchantResolver.php

+ 25
- 15
Resolver/MerchantResolver.php Voir le fichier

@@ -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(

Chargement…
Annuler
Enregistrer