public function convertTokensToKeys(array
$context_tokens) { assert($this->
assertValidTokens($context_tokens));
$cacheable_metadata =
new CacheableMetadata();
$optimized_tokens =
$this->
optimizeTokens($context_tokens);
// Iterate over cache contexts that have been optimized away and get their
// cacheability metadata.
foreach (static::
parseTokens(array_diff($context_tokens,
$optimized_tokens)) as $context_token) { [$context_id,
$parameter] =
$context_token;
$context =
$this->
getService($context_id);
$cacheable_metadata =
$cacheable_metadata->
merge($context->
getCacheableMetadata($parameter));
} sort($optimized_tokens);
$keys =
[];
foreach (array_combine($optimized_tokens,
static::
parseTokens($optimized_tokens)) as $context_token =>
$context) { [$context_id,
$parameter] =
$context;
$keys[] = '[' .
$context_token . ']=' .
$this->
getService($context_id)->
getContext($parameter);
}