Process the data and return the answers that should be filled in beforehand.

Storing the changed values is handled by the calling function.

@param \Gems_Tracker_Token $token Gems token object
@return array Containing the changed values
519063
public function processTokenInsertion(\Gems_Tracker_Token $token)
    {
        if ($token->hasSuccesCode() && (! $token->isCompleted())) {
            // Preparation for a more general object class
            $surveyId   = $token->getSurveyId();

            $next = $token->getRespondentTrack()->getFirstToken();
            while ($next) {

                if ($next->hasSuccesCode() && $next->isCompleted()) {
                    // Check first on survey id and when that does not work by name.
                    if ($next->getSurveyId() == $surveyId) {
                        return $next->getRawAnswers();
                    }
                }
                $next = $next->getNextToken();
            }
        }
    }
589983
protected function getTokenData(Token $token)
    {
        return [
            'id' => $token->getId(),
            'expires' => $token->getExpiresAt()->format(\DateTime::ISO8601),
        ];
    }
413664
public function processChangedRespondent(\Gems_Tracker_Respondent $respondent)
    {
        $changes    = 0;
        $tracker    = $this->loader->getTracker();
        $respTracks = $tracker->getRespondentTracks($respondent->getId(), $respondent->getOrganizationId());
        $userId     = $this->currentUser->getUserId();

        foreach($respTracks as $respondentTrack) {
            if ($respondentTrack instanceof \Gems_Tracker_RespondentTrack) {
                $changes += $respondentTrack->checkTrackTokens($userId);
            }
        }
        // \MUtil_Echo::track('Hi there! ' . $changes);

        return (boolean) $changes;
    }
325386
public function getTriggers($token)
    {
        $fmt = $this->getFormatter(false);

        if (!is_string($token) || strpos($token, ' ') === false) {
            throw new \Erebot\InvalidValueException($fmt->_('Invalid token'));
        }

        list($chan, $pos) = explode(' ', $token);

        if (!isset($this->triggers[$chan][$pos])) {
            throw new \Erebot\NotFoundException($fmt->_('No such triggers'));
        }

        return $this->triggers[$chan][$pos];
    }
347269
public function getByToken($token)
    {
        if (null === $this->profiler) {
            throw new \RuntimeException('Invalid profiler instance.');
        }

        $profile = $this->profiler->loadProfile($token);

        // In case no results were found
        if (!$profile instanceof Profile) {
            return array(array(), 0);
        }

        try {
            /** @var TranslationDataCollector $collector */
            $collector = $profile->getCollector('translation');
            $messages = $collector->getMessages();

            $transUnits = array();
            foreach ($messages as $message) {
                $transUnit = $this->storage->getTransUnitByKeyAndDomain($message['id'], $message['domain']);

                if ($transUnit instanceof TransUnit) {
                    $transUnits[] = $transUnit;
                } elseif (true === $this->createMissing) {
                    $transUnits[] = $transUnit = $this->transUnitManager->create($message['id'], $message['domain'], true);
                }

                // Also store the translation if profiler state was defined
                if (!$transUnit->hasTranslation($message['locale']) && $message['state'] === DataCollectorTranslator::MESSAGE_DEFINED) {
                    $file = $this->fileManager->getFor(sprintf('%s.%s.%s', $message['domain'], $message['locale'], $this->defaultFileFormat));

                    $this->transUnitManager->addTranslation($transUnit, $message['locale'], $message['translation'], $file, true);
                }
            }

            return array($transUnits, count($transUnits));

        } catch (\InvalidArgumentException $e) {

            // Translation collector is a 2.7 feature
            return array(array(), 0);
        }
    }
593347
public function getRoundAnswerSnippets(\Gems_Tracker_Token $token)
    {
        $this->_ensureRounds();
        $roundId = $token->getRoundId();

        if (isset($this->_rounds[$roundId]['gro_display_event']) && $this->_rounds[$roundId]['gro_display_event']) {
            $event = $this->events->loadSurveyDisplayEvent($this->_rounds[$roundId]['gro_display_event']);

            return $event->getAnswerDisplaySnippets($token);
        }
    }
378237
public function inSource(\Gems_Tracker_Token $token)
    {
        $source = $this->getSource();
        return $source->inSource($token, $this->_surveyId, $this->_gemsSurvey['gsu_surveyor_id']);
    }
590277
private function getContentsOfTokenType(int $token): array
    {
        $helper = new PropertyHelper($this->file);
        $tokenPoss = TokenHelper::findNextAll(
            $this->file->getBaseFile(),
            [$token],
            $this->stackPos + 1,
            $this->token['scope_closer']
        );

        $foundContentsOrg = [];

        foreach ($tokenPoss as $tokenPos) {
            $tokenContentPos = $tokenPos;

            if (($token === T_VARIABLE) && (!$helper->isProperty($tokenPos))) {
                continue;
            }

            if ($token !== T_VARIABLE) {
                $tokenContentPos = $this->file->findNext([T_STRING], $tokenPos);
            }

            $foundContentsOrg[$tokenContentPos] = $this->tokens[$tokenContentPos]['content'];
        }

        return $foundContentsOrg;
    }
234227
private function _processTODO($token) {
		if ($this->_isActive('showTODOs')) {
			$text = $token->text;
			$todoStr = stripos($text, 'TODO');
			if ($todoStr !== FALSE) {

				$todoMsg = substr($text, $todoStr + 4);

				// Take the first line only
				$lines = preg_split('/\r\n|\r|\n/', $todoMsg);
				$todoMsg = $lines[0];

				// Remove a ':' from the start
				$colonPos = stripos($todoMsg, ':');
				if ($todoStr !== FALSE) {
					$todoMsg = substr($todoMsg, $colonPos + 1);
				}

				// Trim
				$todoMsg = trim($todoMsg);

				$msg = $this->_getMessage('TODO', $todoMsg);
				$this->_writeError('showTODOs', $msg, $token->line);
			}
		}
	}
534849
public function withToken(Token $token)
    {
        $card = $this->with('token', $token);

        if (null !== $card->number) {
            $lastDigits = strlen($card->number) <= 4
                ? $card->number :
                substr($card->number, -4);
            $card->number = "XXXX-XXXX-XXXX-" . $lastDigits;
        }

        $card->cvv = null;

        return $card;
    }
453216
public function checkToken($token)
    {
        $actualTime = microtime(true);
        $timeLimit  = $this->getTimeLimit();

        $pool = $this->getStore()->getTokens();
        if(!is_null($pool)){

            foreach($pool as $savedToken){
                if($savedToken['token'] == $token){
                    if($timeLimit > 0){
                        return $savedToken['ts'] + $timeLimit > $actualTime;
                    }
                    return true;
                }
            }
        }
        return false;
    }
540120
public function getActiveRoundToken($roundId, \Gems_Tracker_Token $token = null)
    {
        if ((null !== $token) && $token->hasSuccesCode()) {
            // Cache the token
            //
            // WARNING: This may cause bugs for tracks where two tokens exists
            // with this roundId and a success reception code, but this does speed
            // this function with track engines where that should not occur.
            $this->_activeTokens[$token->getRoundId()] = $token;
        }

        // Nothing to find
        if (! $roundId) {
            return null;
        }

        // Use array_key_exists since there may not be a valid round
        if (! array_key_exists($roundId, $this->_activeTokens)) {
            $tokenSelect = $this->tracker->getTokenSelect();
            $tokenSelect->andReceptionCodes()
                    ->forRespondentTrack($this->_respTrackId)
                    ->forRound($roundId)
                    ->onlySucces();

            // \MUtil_Echo::track($tokenSelect->__toString());

            if ($tokenData = $tokenSelect->fetchRow()) {
                $this->_activeTokens[$roundId] = $this->tracker->getToken($tokenData);
            } else {
                $this->_activeTokens[$roundId] = null;
            }
        }

        return $this->_activeTokens[$roundId];
    }
385589
public function getAnswerDisplaySnippets(\Gems_Tracker_Token $token)
    {
        $snippets = parent::getAnswerDisplaySnippets($token);
        if (!is_array($snippets)) {
        	$snippets = array($snippets);
        }
        // Add the ScoreChartsSnippet
        $snippets[] = 'Survey_Display_ScoreChartsSnippet';
        return $snippets;
    }
806489
public function getTokenInfo(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId, array $fields = null)
    {
        if (! $token->cacheHas(self::CACHE_TOKEN_INFO)) {
            if (null === $sourceSurveyId) {
                $sourceSurveyId = $this->_getSid($surveyId);
            }

            $lsTokens = $this->_getTokenTableName($sourceSurveyId);
            $tokenId  = $this->_getToken($token->getTokenId());

            $sql = 'SELECT *
                FROM ' . $lsTokens . '
                WHERE token = ? LIMIT 1';

            try {
                $result = $this->getSourceDatabase()->fetchRow($sql, $tokenId);
            } catch (\Zend_Db_Statement_Exception $exception) {
                $this->logger->logError($exception, $this->request);
                $result = false;
            }

            $token->cacheSet(self::CACHE_TOKEN_INFO, $result);
        } else {
            $result = $token->cacheGet(self::CACHE_TOKEN_INFO);
        }

        if ($fields !== null) $result = array_intersect_key((array) $result, array_flip($fields));

        return $result;
    }
438840
protected function getValueOfToken(array $token)
    {
        switch ($token[Lexer::TYPE]) {
            case Lexer::T_QUOTED_STRING:
                return substr($token[Lexer::VALUE], 1, -1);

            case Lexer::T_NUMBER:
                return (float)$token[Lexer::VALUE];

            case Lexer::T_TRUE:
                return true;

            case Lexer::T_FALSE:
                return false;

            case Lexer::T_NULL:
                return null;
        }

        return null;
    }
1080788
public function parse(Token $token)
    {
        $value = $this->tokenizer->detokenize($token->getValue());
        $realValue = preg_replace('/^<\((.*)\)>$/', '<identity($1)>', $value);

        return $this->decoratedTokenParser->parse(
            new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE))
        );
    }
510322
private function _processSquareBracketOpen($token) {

		// If the [ is preceded by = we are in a array declaration
		if ($this->tokenizer->checkPreviousValidToken(T_EQUAL)) {

			$stackitem = new StatementItem();
			$stackitem->line = $token->line;
			$stackitem->type = 'ARRAY';
			$stackitem->name = 'square_bracket_open';

			$this->statementStack->push($stackitem);
		}
	}