|
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Services ; |
|
|
|
|
|
|
|
use ConnectHolland\CookieConsentBundle\Cookie\CookieChecker; |
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
use Lc\ShopBundle\Context\MerchantUtilsInterface; |
|
|
|
use Symfony\Component\HttpFoundation\Cookie ; |
|
|
@@ -17,9 +18,10 @@ class UserUtils |
|
|
|
protected $requestStack ; |
|
|
|
protected $visitorRepository ; |
|
|
|
protected $merchantUtils ; |
|
|
|
protected $cookieChecker ; |
|
|
|
|
|
|
|
public function __construct(ParameterBagInterface $parameterBag, EntityManagerInterface $em, Utils $utils, |
|
|
|
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils) |
|
|
|
RequestStack $requestStack, MerchantUtilsInterface $merchantUtils, CookieChecker $cookieChecker) |
|
|
|
{ |
|
|
|
$this->em = $em ; |
|
|
|
$this->parameterBag = $parameterBag ; |
|
|
@@ -27,6 +29,7 @@ class UserUtils |
|
|
|
$this->requestStack = $requestStack ; |
|
|
|
$this->visitorRepository = $this->em->getRepository($this->em->getClassMetadata(VisitorInterface::class)->getName()) ; |
|
|
|
$this->merchantUtils = $merchantUtils ; |
|
|
|
$this->cookieChecker = $cookieChecker ; |
|
|
|
} |
|
|
|
|
|
|
|
public function getCookieNameVisitor() |
|
|
@@ -46,7 +49,9 @@ class UserUtils |
|
|
|
|
|
|
|
public function setCookieVisitor($response, $cookie) |
|
|
|
{ |
|
|
|
$response->headers->setCookie(Cookie::create($this->getCookieNameVisitor(), $this->cryptCookie($cookie), 0, '/', $this->utils->getCookieDomain())); |
|
|
|
if($this->cookieChecker->isCategoryAllowedByUser('site')) { |
|
|
|
$response->headers->setCookie(Cookie::create($this->getCookieNameVisitor(), $this->cryptCookie($cookie), 0, '/', $this->utils->getCookieDomain())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function getVisitor($cookie) |