On this page
public static function CacheContextsManager::parseTokens
public static CacheContextsManager::parseTokens(array $context_tokens)
Parses cache context tokens into context IDs and optional parameters.
Parameters
string[] $context_tokens: An array of cache context tokens.
Return value
array An array with the parsed results, with each result being an array containing:
- The cache context ID.
- The associated parameter (for a calculated cache context), or NULL if there is no parameter.
File
- core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php, line 233
Class
- CacheContextsManager
- Converts cache context tokens into cache keys.
Namespace
Drupal\Core\Cache\ContextCode
public static function parseTokens(array $context_tokens) {
$contexts_with_parameters = [];
foreach ($context_tokens as $context) {
$context_id = $context;
$parameter = NULL;
if (strpos($context, ':') !== FALSE) {
list($context_id, $parameter) = explode(':', $context, 2);
}
$contexts_with_parameters[] = [$context_id, $parameter];
}
return $contexts_with_parameters;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Cache!Context!CacheContextsManager.php/function/CacheContextsManager::parseTokens/8.1.x