Browse Source

MerchantResolver : ajout méthode getMerchantUserViaCookie()

packProduct
Guillaume 3 years ago
parent
commit
7171fc95dd
1 changed files with 23 additions and 12 deletions
  1. +23
    -12
      Resolver/MerchantResolver.php

+ 23
- 12
Resolver/MerchantResolver.php View File

$user = $this->security->getUser(); $user = $this->security->getUser();
} }


$merchants = $this->merchantStore->getOnline();

if ($user) { if ($user) {
return $user->getFavoriteMerchant(); 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; 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;
}

} }

Loading…
Cancel
Save