src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php
private function setTargetGroupHeader(Request $request, CacheInvalidation $kernel)
    {
        $hadValidTargetGroup = true;
        $visitorTargetGroup = $request->cookies->get(static::TARGET_GROUP_COOKIE);
        $visitorSession = $request->cookies->get(static::VISITOR_SESSION_COOKIE);

        if (null === $visitorTargetGroup || null === $visitorSession) {
            $hadValidTargetGroup = false;
            $visitorTargetGroup = $this->requestTargetGroup($request, $kernel, $visitorTargetGroup);
        }

        if ($request->isMethodCacheable()) {
            // add the target group as separate header to vary on it
            $request->headers->set(static::TARGET_GROUP_HEADER, (string) $visitorTargetGroup);
        }

        return $hadValidTargetGroup;
    }
private function setTargetGroupHeader(Request $request, CacheInvalidation $kernel)
    {
        $hadValidTargetGroup = true;
        $visitorTargetGroup = $request->cookies->get(static::TARGET_GROUP_COOKIE);
        $visitorSession = $request->cookies->get(static::VISITOR_SESSION_COOKIE);

        if (null === $visitorTargetGroup || null === $visitorSession) {
            $hadValidTargetGroup = false;
            $visitorTargetGroup = $this->requestTargetGroup($request, $kernel, $visitorTargetGroup);
        }

        if ($request->isMethodCacheable()) {
            // add the target group as separate header to vary on it
            $request->headers->set(static::TARGET_GROUP_HEADER, (string) $visitorTargetGroup);
        }

        return $hadValidTargetGroup;
    }
private function setTargetGroupHeader ( Request $ request , CacheInvalidation $ kernel ) { $ hadValidTargetGroup = true ; $ visitorTargetGroup = $ request -> cookies -> get ( static :: TARGET_GROUP_COOKIE ) ; $ visitorSession = $ request -> cookies -> get ( static :: VISITOR_SESSION_COOKIE ) ; if ( null === $ visitorTargetGroup || null === $ visitorSession ) { $ hadValidTargetGroup = false ; $ visitorTargetGroup = $ this -> requestTargetGroup ( $ request , $ kernel , $ visitorTargetGroup ) ; } if ( $ request -> isMethodCacheable ( ) ) { // add the target group as separate header to vary on it $ request -> headers -> set ( static :: TARGET_GROUP_HEADER , ( string ) $ visitorTargetGroup ) ; } return $ hadValidTargetGroup ; }
Sets the target group header based on an existing cookie, so that the application can adapt the content according
to it. If the cookie didn't exist yet, another request is fired in order to set the value for the cookie.

Returns true if the cookie was already set and false otherwise.

@param Request $request
@param CacheInvalidation $kernel

@return bool
Sets the target group header based on an existing cookie so that the application can adapt the content according to it . If the cookie didn t exist yet another request is fired in order to set the value for the cookie .