Returns a snippet name that can be used to display the answers to the token or nothing.

@param \Gems_Tracker_Token $token
@return array Of snippet names
492749
public function getAnswerSnippetNames(\Gems_Tracker_Token $token)
    {
        if (isset($this->_gemsSurvey['gsu_display_event'])) {
            $event = $this->events->loadSurveyDisplayEvent($this->_gemsSurvey['gsu_display_event']);

            return $event->getAnswerDisplaySnippets($token);
        }
    }
1001596
public function getCompletionTime(\Gems_Tracker_Token $token)
    {
        $source = $this->getSource();
        return $source->getCompletionTime($token, $this->_surveyId, $this->_gemsSurvey['gsu_surveyor_id']);
    }
959238
public function videosFollowed($token = null)
    {
        $token = $this->getToken($token);

        $videos = $this->client->get('https://api.twitch.tv/kraken/videos/followed?oauth_token=' . $token);

        return $videos->json();
    }
162883
public function parse(Twig_Token $token)
    {
        $stream = $this->parser->getStream();

        $info = array();
        $first = $this->parser->getExpressionParser()->parseExpression();

        if ($stream->test(Twig_Token::BLOCK_END_TYPE)) {
            $info['expr']= $first;
        } else {
            $info['name']= $first;
            $info['expr']= $this->parser->getExpressionParser()->parseExpression();
            if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) {
                $info['prio']= $this->parser->getExpressionParser()->parseExpression();
            }
        }

        $node = new AnnotateNode($info);
        $stream->expect(\Twig_Token::BLOCK_END_TYPE);

        return $node;
    }
937185
protected function _isTokenInFilter(\Gems_Tracker_Token $token)
    {
        $result = false;

        // Only if token has a success code
        if ($token->getReceptionCode()->isSuccess()) {
            $result = true;
        }

        if ($result) {
            $tokenInfo = array(
                'code'     => $token->getSurvey()->getCode(),
                'surveyid' => $token->getSurveyId(),
                'tokenid'  => $token->getTokenId()
            );

            // Now check if the tokenfilter is true
            if (empty($this->tokenFilter)) {
                $result = true;
            } else {
                $result = false;
                // Now read the filter and split by track code or track id
                foreach ($this->tokenFilter as $filter)
                {
                    $remaining = array_diff_assoc($filter, $tokenInfo);
                    if (empty($remaining)) {
                        $result = true;
                        break;
                    }
                }
            }
        }

        return $result;
    }
411099
public function stem($token) 
    {
        if(strlen($token) < $this->minimumTokenLength) {
            return $token;
        }        
        return preg_replace("/".$this->regexExpression."/i", '', $token);        
    }
1227085
public function setNextToken(\Gems_Tracker_Token $token)
    {
        $this->_nextToken = $token;

        $token->_previousToken = $this;

        return $this;
    }
778609
private function getLinksField($token)
    {
        $uri = $this->service->getInvoicePdfUri($token);
        $text = ucfirst($this->t('invoice'));
        $title = sprintf($this->t('open_as_pdf'), $text);
        /** @noinspection HtmlUnknownTarget */
        $invoiceLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf');

        $uri = $this->service->getPackingSlipUri($token);
        $text = ucfirst($this->t('packing_slip'));
        $title = sprintf($this->t('open_as_pdf'), $text);
        /** @noinspection HtmlUnknownTarget */
        $packingSlipLink = sprintf('<a class="%4$s" href="%1$s" title="%3$s">%2$s</a>', $uri, $text, $title, 'pdf');

        $fields = array(
            'links' => array(
                'type' => 'markup',
                'label' => $this->t('documents'),
                'value' => "$invoiceLink $packingSlipLink",
            ),
        );
        return $fields;
    }
839011
public function parseToken($token) {
        $token = base64_decode($token);
        $parts = explode(':', $token, 2);

        return [array_get($parts, 0), array_get($parts, 1)];
    }
33798
protected function getTokenFormatter($token)
    {
        $formatters = $this->getTokenFormatters();

        if (!array_key_exists($token, $formatters)) {
            $message = "The class %s does not know how to format the %s token\n".
                       "Have you added it in the getTokenFormatters() method?";

            throw new Exception(sprintf($message, get_called_class(), $token));
        }

        return $formatters[$token];
    }
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;
    }
812554
public function getTokenGuard(Token $token, $guards)
    {
        $providers = GuardChecker::getGuardsProviders($guards);

        // use only guard associated to access token provider
        return $providers->has($token->provider) ? [$providers->get($token->provider)] : [];
    }
331324
public function removeToken($token)
    {
        if ($token instanceof \Gems_Tracker_Token) {
            $tokenId = $token->getTokenId();
        } else {
            $tokenId = $token;
        }
        unset($this->_tokens[$tokenId]);

        return $this;
    }
491962
public function processTokenData(\Gems_Tracker_Token $token)
    {
        if (! $token->getReceptionCode()->isSuccess()) {
            return;
        }
        $answers = $token->getRawAnswers();

        if (isset($answers['informedconsent'])) {
            $consent = $this->util->getConsent($answers['informedconsent']);

            if ($consent->exists) {
                // Is existing consent description as answer
                $consentCode = $consent->getDescription();
            } else {
                if ($answers['informedconsent']) {
                    // Uses start of consent description as answer (LS has only 5 chars for an answer option)
                    $consentCode = $this->db->fetchOne(
                            "SELECT gco_description FROM gems__consents WHERE gco_description LIKE ? ORDER BY gco_order",
                            $answers['informedconsent'] . '%'
                            );
                } else {
                    $consentCode = false;
                }

                if (! $consentCode) {
                    if ($answers['informedconsent']) {
                        // Code not found, use first positive consent
                        $consentCode = $this->db->fetchOne(
                                "SELECT gco_description FROM gems__consents WHERE gco_code != ? ORDER BY gco_order",
                                $this->util->getConsentRejected()
                                );
                    } else {
                        // Code not found, use first negative consent
                        $consentCode = $this->db->fetchOne(
                                "SELECT gco_description FROM gems__consents WHERE gco_code = ? ORDER BY gco_order",
                                $this->util->getConsentRejected()
                                );
                    }
                }
            }

            $respondent = $token->getRespondent();
            $values = array(
                'gr2o_patient_nr'      => $respondent->getPatientNumber(),
                'gr2o_id_organization' => $respondent->getOrganizationId(),
                'gr2o_consent'         => $consentCode,
            );
            $model = $respondent->getRespondentModel();
            $model->save($values);

            if ($model->getChanged()) {
                // Refresh the token so it has the new consent code
                $token->refresh();

                // Make sure the NEW consent is applied to this survey itself
                $survey = $token->getSurvey();
                $survey->copyTokenToSource($token, '');
            }
        }

        return false;
    }
408654
private function getSolrFieldPrefix(WordToken $token)
    {
        if ($token->domain === '') {
            return '';
        }

        if (isset($this->domainFieldMap[$token->domain])) {
            return $this->domainFieldMap[$token->domain] . ':';
        }

        return $this->defaultFieldName . ':';
    }
450321
public function decorate(Token $token): string
    {
        $style = $token->style();
        $value = $token->value();

        foreach ($this->decorators as $decorator) {
            $value = $decorator->decorate($style, $value);
        }

        return $value;
    }
109871
private function generateSnippets()
    {
        if ($this->snippetsGenerated) {
            return null;
        }

        $snippetsSet = array();
        foreach ($this->undefinedSteps as $i => $undefinedStep) {
            $snippet = $this->generateSnippet($undefinedStep->getEnvironment(), $undefinedStep->getStep());

            if (!$snippet) {
                continue;
            }

            if (!isset($snippetsSet[$snippet->getHash()])) {
                $snippetsSet[$snippet->getHash()] = array();
            }

            $snippetsSet[$snippet->getHash()][] = $snippet;
            unset($this->undefinedSteps[$i]);
        }

        $this->snippets = array_values(
            array_map(
                function (array $snippets) {
                    return new AggregateSnippet($snippets);
                },
                $snippetsSet
            )
        );
        $this->undefinedSteps = array_values($this->undefinedSteps);
        $this->snippetsGenerated = true;
    }