src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupEvaluationController.php
public function targetGroupAction(Request $request)
    {
        $currentTargetGroup = null;
        if ($request->headers->has($this->targetGroupHeader)) {
            $currentTargetGroup = $this->targetGroupRepository->find($request->headers->get($this->targetGroupHeader));
        }

        $targetGroup = $this->targetGroupEvaluator->evaluate(
            $currentTargetGroup ? TargetGroupRuleInterface::FREQUENCY_SESSION : TargetGroupRuleInterface::FREQUENCY_VISITOR,
            $currentTargetGroup
        );

        $response = new Response(null, 200, [
            $this->targetGroupHeader => $targetGroup ? $targetGroup->getId() : 0,
        ]);

        return $response;
    }
public function targetGroupAction(Request $request)
    {
        $currentTargetGroup = null;
        if ($request->headers->has($this->targetGroupHeader)) {
            $currentTargetGroup = $this->targetGroupRepository->find($request->headers->get($this->targetGroupHeader));
        }

        $targetGroup = $this->targetGroupEvaluator->evaluate(
            $currentTargetGroup ? TargetGroupRuleInterface::FREQUENCY_SESSION : TargetGroupRuleInterface::FREQUENCY_VISITOR,
            $currentTargetGroup
        );

        $response = new Response(null, 200, [
            $this->targetGroupHeader => $targetGroup ? $targetGroup->getId() : 0,
        ]);

        return $response;
    }
public function targetGroupAction ( Request $ request ) { $ currentTargetGroup = null ; if ( $ request -> headers -> has ( $ this -> targetGroupHeader ) ) { $ currentTargetGroup = $ this -> targetGroupRepository -> find ( $ request -> headers -> get ( $ this -> targetGroupHeader ) ) ; } $ targetGroup = $ this -> targetGroupEvaluator -> evaluate ( $ currentTargetGroup ? TargetGroupRuleInterface :: FREQUENCY_SESSION : TargetGroupRuleInterface :: FREQUENCY_VISITOR , $ currentTargetGroup ) ; $ response = new Response ( null , 200 , [ $ this -> targetGroupHeader => $ targetGroup ? $ targetGroup -> getId ( ) : 0 , ] ) ; return $ response ; }
Takes the request and evaluates a target group based on the request.

@param Request $request

@return Response
Takes the request and evaluates a target group based on the request .