eZ\Publish\Core\Repository\Helper\NameSchemaService::resolveToken PHP Method

resolveToken() protected method

Looks up the value $token should be replaced with and returns this as a string. Meta strings denoting token groups are automatically inferred.
protected resolveToken ( string $token, array $titles, array $groupLookupTable ) : string
$token string
$titles array
$groupLookupTable array
return string
    protected function resolveToken($token, $titles, $groupLookupTable)
    {
        $replaceString = '';
        $tokenParts = $this->tokenParts($token);
        foreach ($tokenParts as $tokenPart) {
            if ($this->isTokenGroup($tokenPart)) {
                $replaceString = $groupLookupTable[$tokenPart];
                $groupTokenArray = $this->extractTokens($replaceString);
                foreach ($groupTokenArray as $groupToken) {
                    $replaceString = str_replace($groupToken, $this->resolveToken($groupToken, $titles, $groupLookupTable), $replaceString);
                }
                // We want to stop after the first matching token part / identifier is found
                // <id1|id2> if id1 has a value, id2 will not be used.
                // In this case id1 or id1 is a token group.
                break;
            } else {
                if (array_key_exists($tokenPart, $titles) && $titles[$tokenPart] !== '' && $titles[$tokenPart] !== null) {
                    $replaceString = $titles[$tokenPart];
                    // We want to stop after the first matching token part / identifier is found
                    // <id1|id2> if id1 has a value, id2 will not be used.
                    break;
                }
            }
        }
        return $replaceString;
    }