function _patterns_recurse_tokens in Patterns 5
Same name and namespace in other branches
- 6.2 patterns.module \_patterns_recurse_tokens()
- 6 patterns.module \_patterns_recurse_tokens()
- 7.2 includes/core/token.inc \_patterns_recurse_tokens()
- 7 includes/core/token.inc \_patterns_recurse_tokens()
Recurse an array and replace with tokens @ This is used instead of array_walk_recursive because of some strange issues with token_get_values failing.
1 call to _patterns_recurse_tokens()
File
- ./
patterns.module, line 1313 - Enables extremely simple adding/removing features to your site with minimal to no configuration
Code
function _patterns_recurse_tokens(&$object, $identifiers) {
foreach ($object as $key => $value) {
if (is_array($value)) {
_patterns_recurse_tokens($object[$key], $identifiers);
}
else {
if (is_scalar($value)) {
$old_key = $key;
_patterns_replace_tokens($object[$key], $key, $identifiers);
// The key was changed, change it
if ($old_key != $key) {
$keys = array_keys($object);
$keys[array_search($old_key, $keys)] = $key;
$object = array_combine($keys, array_values($object));
}
}
}
}
}