public function Blocache::prepareContextsToStorage in Blocache (Block Cache Control) 8
Prepares the cache contexts for storage into third-party setting.
Parameters
array $values: The context values from block configuration.
The array must have key => value pairs respecting the standard:
- {cache_context_name} => 'cache context name'
- {cache_context_name}_arg => 'cache context argument'.
Return value
array Returns an array with values respecting the standard: {cache_context_name}:{cache_context_name_arg}
File
- src/
Blocache.php, line 61
Class
- Blocache
- Class Blocache.
Namespace
Drupal\blocacheCode
public function prepareContextsToStorage(array $values) {
$contexts = [];
$i = 0;
foreach ($values as $key => $value) {
$count = strlen('__arg');
if (substr($key, -$count) === '__arg') {
continue;
}
if ($value === 1) {
$contexts[$i] = $key;
if ($arg = $values[$key . '__arg']) {
$contexts[$i] .= ':' . $arg;
}
$i++;
}
}
return $contexts;
}