|
|
@@ -142,24 +142,35 @@ class MerchantResolver |
|
|
|
$user = $this->security->getUser(); |
|
|
|
} |
|
|
|
|
|
|
|
$merchants = $this->merchantStore->getOnline(); |
|
|
|
|
|
|
|
if ($user) { |
|
|
|
return $user->getFavoriteMerchant(); |
|
|
|
} else { |
|
|
|
$merchantCurrentId = $this->requestStack->getCurrentRequest()->cookies->getInt( |
|
|
|
$this->parameterBag->get('app.cookie_name_merchant_current') |
|
|
|
); |
|
|
|
if ($merchantCurrentId) { |
|
|
|
foreach ($merchants as $merchant) { |
|
|
|
if ($merchant->getId() == $merchantCurrentId) { |
|
|
|
return $merchant; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
$merchantCurrent = $this->getMerchantUserViaCookie(); |
|
|
|
if($merchantCurrent) { |
|
|
|
return $merchantCurrent; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public function getMerchantUserViaCookie() |
|
|
|
{ |
|
|
|
$merchants = $this->merchantStore->getOnline(); |
|
|
|
$merchantCurrentId = $this->requestStack->getCurrentRequest()->cookies->getInt( |
|
|
|
$this->parameterBag->get('app.cookie_name_merchant_current') |
|
|
|
); |
|
|
|
|
|
|
|
if ($merchantCurrentId) { |
|
|
|
foreach ($merchants as $merchant) { |
|
|
|
if ($merchant->getId() == $merchantCurrentId) { |
|
|
|
return $merchant; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
} |