private function saveVariation(Experiment $experiment, Variation $variation, UserProfile $userProfile)
    {
        if (is_null($this->_userProfileService)) {
            return;
        }

        $experimentId = $experiment->getId();
        $decision = $userProfile->getDecisionForExperiment($experimentId);
        $variationId = $variation->getId();
        if (is_null($decision)) {
            $decision = new Decision($variationId);
        } else {
            $decision->setVariationId($variationId);
        }

        $userProfile->saveDecisionForExperiment($experimentId, $decision);
        $userProfileMap = UserProfileUtils::convertUserProfileToMap($userProfile);

        try {
            $this->_userProfileService->save($userProfileMap);
            $this->_logger->log(
                Logger::INFO,
                sprintf(
                    'Saved variation "%s" of experiment "%s" for user "%s".',
                    $variation->getKey(),
                    $experiment->getKey(),
                    $userProfile->getUserId()
                )
            );
        } catch (Exception $e) {
            $this->_logger->log(
                Logger::WARNING,
                sprintf(
                    'Failed to save variation "%s" of experiment "%s" for user "%s".',
                    $variation->getKey(),
                    $experiment->getKey(),
                    $userProfile->getUserId()
                )
            );
        }
    }
private function saveVariation(Experiment $experiment, Variation $variation, UserProfile $userProfile)
    {
        if (is_null($this->_userProfileService)) {
            return;
        }

        $experimentId = $experiment->getId();
        $decision = $userProfile->getDecisionForExperiment($experimentId);
        $variationId = $variation->getId();
        if (is_null($decision)) {
            $decision = new Decision($variationId);
        } else {
            $decision->setVariationId($variationId);
        }

        $userProfile->saveDecisionForExperiment($experimentId, $decision);
        $userProfileMap = UserProfileUtils::convertUserProfileToMap($userProfile);

        try {
            $this->_userProfileService->save($userProfileMap);
            $this->_logger->log(
                Logger::INFO,
                sprintf(
                    'Saved variation "%s" of experiment "%s" for user "%s".',
                    $variation->getKey(),
                    $experiment->getKey(),
                    $userProfile->getUserId()
                )
            );
        } catch (Exception $e) {
            $this->_logger->log(
                Logger::WARNING,
                sprintf(
                    'Failed to save variation "%s" of experiment "%s" for user "%s".',
                    $variation->getKey(),
                    $experiment->getKey(),
                    $userProfile->getUserId()
                )
            );
        }
    }
private function saveVariation ( Experiment $ experiment , Variation $ variation , UserProfile $ userProfile ) { if ( is_null ( $ this -> _userProfileService ) ) { return ; } $ experimentId = $ experiment -> getId ( ) ; $ decision = $ userProfile -> getDecisionForExperiment ( $ experimentId ) ; $ variationId = $ variation -> getId ( ) ; if ( is_null ( $ decision ) ) { $ decision = new Decision ( $ variationId ) ; } else { $ decision -> setVariationId ( $ variationId ) ; } $ userProfile -> saveDecisionForExperiment ( $ experimentId , $ decision ) ; $ userProfileMap = UserProfileUtils :: convertUserProfileToMap ( $ userProfile ) ; try { $ this -> _userProfileService -> save ( $ userProfileMap ) ; $ this -> _logger -> log ( Logger :: INFO , sprintf ( 'Saved variation "%s" of experiment "%s" for user "%s".' , $ variation -> getKey ( ) , $ experiment -> getKey ( ) , $ userProfile -> getUserId ( ) ) ) ; } catch ( Exception $ e ) { $ this -> _logger -> log ( Logger :: WARNING , sprintf ( 'Failed to save variation "%s" of experiment "%s" for user "%s".' , $ variation -> getKey ( ) , $ experiment -> getKey ( ) , $ userProfile -> getUserId ( ) ) ) ; } }
Save the given variation assignment to the given user profile.

@param $experiment  Experiment  Experiment for which we are storing the variation.
@param $variation   Variation   Variation the user is bucketed into.
@param $userProfile UserProfile User profile object to which we are persisting the variation assignment.
Save the given variation assignment to the given user profile .