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]; } }