<?php | |||||
namespace Lc\CaracoleBundle\Builder\Merchant; | |||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||||
use Lc\SovBundle\Component\CookieComponent; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Symfony\Component\HttpFoundation\Cookie; | |||||
class MerchantBuilder | |||||
{ | |||||
protected ParameterBagInterface $parameterBag; | |||||
protected CookieComponent $cookieComponent; | |||||
public function __construct( | |||||
ParameterBagInterface $parameterBag, | |||||
CookieComponent $cookieComponent | |||||
) { | |||||
$this->parameterBag = $parameterBag; | |||||
$this->cookieComponent = $cookieComponent; | |||||
} | |||||
public function setCookieMerchantCurrent($response, MerchantInterface $merchant) | |||||
{ | |||||
$response->headers->setCookie( | |||||
Cookie::create( | |||||
$this->parameterBag->get('app.cookie_name_merchant_current'), | |||||
$merchant->getId(), | |||||
0, | |||||
'/', | |||||
$this->cookieComponent->getCookieDomain() | |||||
) | |||||
); | |||||
} | |||||
} |
use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory; | use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory; | ||||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Builder\User\UserBuilder as SovUserBuilder; | |||||
class UserBuilder | |||||
class UserBuilder extends SovUserBuilder | |||||
{ | { | ||||
protected EntityManagerInterface $entityManager; | |||||
public function __construct(EntityManagerInterface $entityManager) | |||||
{ | |||||
$this->entityManager = $entityManager; | |||||
} | |||||
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale) | public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale) | ||||
{ | { |
<?php | |||||
namespace Lc\CaracoleBundle\Builder\User; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use Lc\CaracoleBundle\Factory\User\VisitorFactory; | |||||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | |||||
use Lc\SovBundle\Component\CookieComponent; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Symfony\Component\HttpFoundation\Cookie; | |||||
class VisitorBuilder | |||||
{ | |||||
protected CookieComponent $cookieComponent; | |||||
protected ParameterBagInterface $parameterBag; | |||||
protected EntityManagerInterface $entityManager; | |||||
public function __construct( | |||||
EntityManagerInterface $entityManager, | |||||
CookieComponent $cookieComponent, | |||||
ParameterBagInterface $parameterBag | |||||
) { | |||||
$this->entityManager = $entityManager; | |||||
$this->cookieComponent = $cookieComponent; | |||||
$this->parameterBag = $parameterBag; | |||||
} | |||||
// addVisitor | |||||
public function create(string $cookie, string $ip) | |||||
{ | |||||
$visitorFactory = new VisitorFactory(); | |||||
$visitor = $visitorFactory->create($cookie, $ip); | |||||
$this->entityManager->persist($visitor); | |||||
$this->entityManager->flush(); | |||||
} | |||||
public function update(VisitorInterface $visitor) | |||||
{ | |||||
$totalVisit = $visitor->getTotalVisit() + 1; | |||||
$visitor->setTotalVisit($totalVisit); | |||||
$visitor->setLastAccess(new \DateTime()); | |||||
$this->entityManager->persist($visitor); | |||||
$this->entityManager->flush(); | |||||
} | |||||
// setCookieVisitor | |||||
public function setCookie($response, $cookie) | |||||
{ | |||||
$response->headers->setCookie( | |||||
Cookie::create( | |||||
$this->parameterBag->get('app.cookie_name_visitor'), | |||||
$this->cookieComponent->cryptCookie($cookie), | |||||
new \DateTime('+2 months'), | |||||
'/', | |||||
$this->cookieComponent->getCookieDomain() | |||||
) | |||||
); | |||||
} | |||||
// updateVisitorCookie | |||||
public function updateCookie($response) | |||||
{ | |||||
$response->headers->setCookie( | |||||
Cookie::create( | |||||
$this->parameterBag->get('app.cookie_name_visitor'), | |||||
$this->cookieComponent->cryptCookie($this->getVisitorCurrent()->getCookie()), | |||||
new \DateTime('+2 months'), | |||||
'/', | |||||
$this->cookieComponent->getCookieDomain() | |||||
) | |||||
); | |||||
} | |||||
} |
class VisitorFactory extends AbstractFactory | class VisitorFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(): VisitorInterface | |||||
public function create(string $cookie, string $ip): VisitorInterface | |||||
{ | { | ||||
$visitor = new Visitor(); | $visitor = new Visitor(); | ||||
$visitor->setCookie($cookie); | |||||
$visitor->setIp($ip); | |||||
$visitor->setTotalVisit(1); | |||||
$visitor->setLastAccess(new \DateTime()); | |||||
return $visitor; | return $visitor; | ||||
} | } | ||||
$this->merchantResolver = $merchantResolver; | $this->merchantResolver = $merchantResolver; | ||||
} | } | ||||
public function getAsArray() | public function getAsArray() | ||||
{ | { | ||||
$query = $this->query->create(); | $query = $this->query->create(); |
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterByDevAlias(string $devAlias) | |||||
{ | |||||
return $this->andWhere('.devAlias LIKE :devAlias') | |||||
->setParameter('devAlias', $devAlias); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Merchant; | namespace Lc\CaracoleBundle\Repository\Merchant; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
class MerchantStore extends AbstractStore | class MerchantStore extends AbstractStore | ||||
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getOneByDevAlias(string $devAlias): ?MerchantInterface | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterByDevAlias($devAlias); | |||||
return $query->findOne(); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||||
use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | ||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
class ProductFamilyStore extends AbstractStore | class ProductFamilyStore extends AbstractStore | ||||
{ | { | ||||
protected ProductFamilyRepositoryQuery $query; | protected ProductFamilyRepositoryQuery $query; | ||||
protected PriceResolver $priceResolver; | |||||
public function __construct(ProductFamilyRepositoryQuery $query) | |||||
public function __construct(ProductFamilyRepositoryQuery $query, PriceResolver $priceResolver) | |||||
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
$this->priceResolver = $priceResolver; | |||||
} | } | ||||
public function isOneProductAvailableAddCart(array $products): bool | public function isOneProductAvailableAddCart(array $products): bool | ||||
return false; | return false; | ||||
} | } | ||||
public function getMultiplyingFactor($productFamily) | |||||
{ | |||||
if ($productFamily->getBehaviorPrice() == ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE) { | |||||
if ($productFamily->getBuyingPrice() > 0) { | |||||
return number_format( | |||||
$this->priceResolver->getPriceWithTax($productFamily) / $productFamily->getBuyingPrice(), | |||||
3 | |||||
); | |||||
} | |||||
} elseif ($productFamily->getBehaviorPrice() == ProductFamilyModel::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) { | |||||
if ($productFamily->getBuyingPriceByRefUnit() > 0) { | |||||
return number_format( | |||||
$this->priceResolver->getPriceByRefUnitWithTax( | |||||
$productFamily | |||||
) / $productFamily->getBuyingPriceByRefUnit(), | |||||
3 | |||||
); | |||||
} | |||||
} | |||||
} | |||||
public function getCheapestProduct(ProductFamilyInterface $productFamily) | |||||
{ | |||||
$priceResolver = $this->priceResolver; | |||||
return $this->getCheapestOrMostExpensiveProduct( | |||||
$productFamily, | |||||
function ($a, $b) use ($priceResolver) { | |||||
return $priceResolver->getPriceWithTaxAndReduction( | |||||
$a | |||||
) > $priceResolver->getPriceWithTaxAndReduction($b); | |||||
}, | |||||
true | |||||
); | |||||
} | |||||
public function getCheapestProductByRefUnit(ProductFamilyInterface $productFamily) | |||||
{ | |||||
$priceResolver = $this->priceResolver; | |||||
return $this->getCheapestOrMostExpensiveProduct( | |||||
$productFamily, | |||||
function ($a, $b) use ($priceResolver) { | |||||
return $priceResolver->getPriceByRefUnitWithTaxAndReduction( | |||||
$a | |||||
) > $priceResolver->getPriceByRefUnitWithTaxAndReduction($b); | |||||
}, | |||||
false | |||||
); | |||||
} | |||||
public function getMostExpensiveProductByRefUnit(ProductFamilyInterface $productFamily) | |||||
{ | |||||
$priceResolver = $this->priceResolver; | |||||
return $this->getCheapestOrMostExpensiveProduct( | |||||
$productFamily, | |||||
function ($a, $b) use ($priceResolver) { | |||||
return $priceResolver->getPriceByRefUnitWithTaxAndReduction( | |||||
$a | |||||
) < $priceResolver->getPriceByRefUnitWithTaxAndReduction($b); | |||||
}, | |||||
false | |||||
); | |||||
} | |||||
private function getCheapestOrMostExpensiveProduct( | |||||
ProductFamilyInterface $productFamily, | |||||
$comparisonFunction, | |||||
$returnSelfIfNotActiveProducts | |||||
) { | |||||
if ($productFamily->getActiveProducts()) { | |||||
$products = $productFamily->getProductsOnline()->getValues(); | |||||
if (count($products) > 0) { | |||||
usort($products, $comparisonFunction); | |||||
return $products[0]; | |||||
} | |||||
} else { | |||||
return $productFamily->getOriginProduct(); | |||||
} | |||||
if ($returnSelfIfNotActiveProducts) { | |||||
return $productFamily; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | |||||
} | } |
class ProductStore extends AbstractStore | class ProductStore extends AbstractStore | ||||
{ | { | ||||
protected ProductRepositoryQuery $query; | protected ProductRepositoryQuery $query; | ||||
protected PriceResolver $priceResolver; | |||||
public function __construct(ProductRepositoryQuery $query, PriceResolver $priceResolver) | public function __construct(ProductRepositoryQuery $query, PriceResolver $priceResolver) | ||||
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
$this->priceResolver = $priceResolver; | |||||
} | |||||
public function getCheapestProduct($productFamily) | |||||
{ | |||||
$priceResolver = $this->priceResolver; | |||||
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceResolver) { | |||||
return $priceResolver->getPriceWithTaxAndReduction($a) > $priceResolver->getPriceWithTaxAndReduction($b); | |||||
}, true); | |||||
} | |||||
public function getCheapestProductByRefUnit(ProductFamilyInterface $productFamily) | |||||
{ | |||||
$priceResolver = $this->priceResolver; | |||||
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceResolver) { | |||||
return $priceResolver->getPriceByRefUnitWithTaxAndReduction($a) > $priceResolver->getPriceByRefUnitWithTaxAndReduction($b); | |||||
}, false); | |||||
} | |||||
public function getMostExpensiveProductByRefUnit(ProductFamilyInterface $productFamily) | |||||
{ | |||||
$priceResolver = $this->priceResolver; | |||||
return $this->getCheapestOrMostExpensiveProduct($productFamily, function ($a, $b) use ($priceResolver) { | |||||
return $priceResolver->getPriceByRefUnitWithTaxAndReduction($a) < $priceResolver->getPriceByRefUnitWithTaxAndReduction($b); | |||||
}, false); | |||||
} | |||||
private function getCheapestOrMostExpensiveProduct(ProductFamilyInterface $productFamily, $comparisonFunction, $returnSelfIfNotActiveProducts) | |||||
{ | |||||
if ($productFamily->getActiveProducts()) { | |||||
$products = $productFamily->getProductsOnline()->getValues(); | |||||
if (count($products) > 0) { | |||||
usort($products, $comparisonFunction); | |||||
return $products[0]; | |||||
} | |||||
} else { | |||||
return $productFamily->getOriginProduct(); | |||||
} | |||||
if ($returnSelfIfNotActiveProducts) { | |||||
return $productFamily; | |||||
} else { | |||||
return false; | |||||
} | |||||
} | } | ||||
} | } |
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterByDevAlias(string $devAlias) | |||||
{ | |||||
return $this | |||||
->andWhere('.devAlias LIKE :devAlias') | |||||
->setParameter('devAlias', $devAlias); | |||||
} | |||||
} | } |
namespace Lc\CaracoleBundle\Repository\Section; | namespace Lc\CaracoleBundle\Repository\Section; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |||||
class SectionStore extends AbstractStore | class SectionStore extends AbstractStore | ||||
{ | { | ||||
use MerchantStoreTrait; | |||||
protected SectionRepositoryQuery $query; | protected SectionRepositoryQuery $query; | ||||
public function __construct(SectionRepositoryQuery $query) | public function __construct(SectionRepositoryQuery $query) | ||||
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
// getSection | |||||
public function getOneByDevAlias(string $devAlias): ?SectionInterface | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query | |||||
->filterByMerchant($this->merchant) | |||||
->filterByDevAlias($devAlias); | |||||
$section = $query->findOne(); | |||||
if (!$section) { | |||||
throw new NotFoundHttpException('La section ' . $devAlias . ' est introuvable'); | |||||
} | |||||
return $section; | |||||
} | |||||
} | } |
{ | { | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterByCookie(string $cookie) | |||||
{ | |||||
return $this | |||||
->andWhere('.cookie LIKE :cookie') | |||||
->setParameter('cookie', $cookie); | |||||
} | |||||
} | } |
{ | { | ||||
$this->query = $query; | $this->query = $query; | ||||
} | } | ||||
public function getOneByCookie(string $cookie) | |||||
{ | |||||
$query = $this->query->create(); | |||||
$query->filterByCookie($cookie); | |||||
return $query->findOne(); | |||||
} | |||||
} | } |
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | ||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; | use Lc\CaracoleBundle\Repository\Merchant\MerchantRepository; | ||||
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | |||||
use Lc\CaracoleBundle\Repository\User\UserMerchantRepository; | use Lc\CaracoleBundle\Repository\User\UserMerchantRepository; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Resolver\UrlResolver; | use Lc\SovBundle\Resolver\UrlResolver; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
class MerchantResolver | class MerchantResolver | ||||
{ | { | ||||
protected $requestStack; | |||||
protected $em; | |||||
protected $urlResolver; | |||||
protected $security; | |||||
protected $currentMerchant; | |||||
protected $merchantRepository; | |||||
protected $userMerrchantRepository; | |||||
protected ?MerchantInterface $currentMerchant; | |||||
protected RequestStack $requestStack; | |||||
protected EntityManagerInterface $em; | |||||
protected UrlResolver $urlResolver; | |||||
protected Security $security; | |||||
protected MerchantRepository $merchantRepository; | |||||
protected UserMerchantRepository $userMerchantRepository; | |||||
protected UrlGeneratorInterface $router; | |||||
protected MerchantStore $merchantStore; | |||||
protected ParameterBagInterface $parameterBag; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $entityManager, | EntityManagerInterface $entityManager, | ||||
UrlResolver $urlResolver, | UrlResolver $urlResolver, | ||||
Security $security, | Security $security, | ||||
MerchantRepository $merchantRepository, | MerchantRepository $merchantRepository, | ||||
UserMerchantRepository $userMerchantRepository | |||||
UserMerchantRepository $userMerchantRepository, | |||||
UrlGeneratorInterface $router, | |||||
MerchantStore $merchantStore, | |||||
ParameterBagInterface $parameterBag | |||||
) { | ) { | ||||
$this->requestStack = $requestStack; | $this->requestStack = $requestStack; | ||||
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->security = $security; | $this->security = $security; | ||||
$this->merchantRepository = $merchantRepository; | $this->merchantRepository = $merchantRepository; | ||||
$this->userMerchantRepository = $userMerchantRepository; | $this->userMerchantRepository = $userMerchantRepository; | ||||
$this->merchantStore = $merchantStore; | |||||
$this->router = $router; | |||||
$this->parameterBag = $parameterBag; | |||||
} | } | ||||
public function getCurrent(): MerchantInterface | public function getCurrent(): MerchantInterface | ||||
{ | { | ||||
if ($this->currentMerchant) { | |||||
if (isset($this->currentMerchant) && $this->currentMerchant) { | |||||
return $this->currentMerchant; | return $this->currentMerchant; | ||||
} | } | ||||
$this->currentMerchant = false; | |||||
$this->currentMerchant = null; | |||||
$request = $this->requestStack->getCurrentRequest(); | $request = $this->requestStack->getCurrentRequest(); | ||||
$merchants = $this->merchantRepository->findAll(); | $merchants = $this->merchantRepository->findAll(); | ||||
$isCli = php_sapi_name() === 'cli'; | $isCli = php_sapi_name() === 'cli'; | ||||
if ($request || $isCli) { | |||||
if ($request || $isCli) { | |||||
if ($isCli || $this->urlResolver->isServerLocalhost()) { | if ($isCli || $this->urlResolver->isServerLocalhost()) { | ||||
foreach ($merchants as $merchant) { | foreach ($merchants as $merchant) { | ||||
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) { | if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) { | ||||
UserInterface $user = null, | UserInterface $user = null, | ||||
MerchantInterface $merchant = null | MerchantInterface $merchant = null | ||||
): ?UserMerchantInterface { | ): ?UserMerchantInterface { | ||||
if ($user === null) { | if ($user === null) { | ||||
$user = $this->security->getUser(); | $user = $this->security->getUser(); | ||||
} | } | ||||
); | ); | ||||
} | } | ||||
public function getUrl($merchant) | |||||
{ | |||||
if ($this->urlResolver->isServerLocalhost()) { | |||||
return $this->router->generate('frontend_home', [], UrlGeneratorInterface::ABSOLUTE_URL); | |||||
} else { | |||||
return $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL); | |||||
} | |||||
} | |||||
public function getMerchantUser(UserInterface $user = null) | |||||
{ | |||||
$merchants = $this->merchantStore->findAll(); | |||||
if ($user) { | |||||
return $user->getMerchant(); | |||||
} 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; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
} | } |
return false; | return false; | ||||
} | } | ||||
public function getDateEndCurrentSale(SectionInterface $section, $formatDate = '', $delimiterDayTime = 'à') | |||||
{ | |||||
// @TODO : à réécrire | |||||
} | |||||
public function getDateBeginNextSale(SectionInterface $section, $formatDate = '', $delimiterDayTime = 'à') | |||||
{ | |||||
// @TODO : à réécrire | |||||
} | |||||
public function getMessages(): array | public function getMessages(): array | ||||
{ | { | ||||
return $this->messages; | return $this->messages; |
{ | { | ||||
use PriceResolverTrait; | use PriceResolverTrait; | ||||
protected $orderProductPriceResolver; | |||||
protected OrderProductPriceResolver $orderProductPriceResolver; | |||||
public function __construct(OrderProductPriceResolver $orderProductPriceResolver) | public function __construct(OrderProductPriceResolver $orderProductPriceResolver) | ||||
{ | { |
<?php | |||||
namespace Lc\CaracoleBundle\Resolver; | |||||
use Lc\CaracoleBundle\Repository\User\VisitorStore; | |||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |||||
use Symfony\Component\HttpFoundation\RequestStack; | |||||
class VisitorResolver | |||||
{ | |||||
protected array $visitor; | |||||
protected RequestStack $requestStack; | |||||
protected ParameterBagInterface $parameterBag; | |||||
protected VisitorStore $visitorStore; | |||||
public function __construct( | |||||
RequestStack $requestStack, | |||||
ParameterBagInterface $parameterBag, | |||||
VisitorStore $visitorStore | |||||
) { | |||||
$this->requestStack = $requestStack; | |||||
$this->parameterBag = $parameterBag; | |||||
$this->visitorStore = $visitorStore; | |||||
} | |||||
public function getCurrent() | |||||
{ | |||||
$cookie = $this->requestStack->getCurrentRequest()->cookies->get( | |||||
$this->parameterBag->get('app.cookie_name_visitor') | |||||
); | |||||
return $this->getVisitor($cookie); | |||||
} | |||||
private function getVisitor($cookie) | |||||
{ | |||||
if (!isset($this->visitor[$cookie])) { | |||||
$this->visitor[$cookie] = $this->visitorStore->getOneByCookie($cookie); | |||||
} | |||||
return $this->visitor[$cookie]; | |||||
} | |||||
} |