function _patterns_recurse_tokens in Patterns 7
Same name and namespace in other branches
- 5 patterns.module \_patterns_recurse_tokens()
- 6.2 patterns.module \_patterns_recurse_tokens()
- 6 patterns.module \_patterns_recurse_tokens()
- 7.2 includes/core/token.inc \_patterns_recurse_tokens()
Recurse an array and replace with tokens @TODO This is used instead of array_walk_recursive because of some strange issues with token_get_values failing.
1 call to _patterns_recurse_tokens()
- patterns_implement_action in includes/
core/ common.inc - Setup and run an action.
File
- includes/
core/ token.inc, line 54 - Functions to related to token module. TODO: Check if we still need them
Code
function _patterns_recurse_tokens(&$object, $identifiers) {
foreach ($object as $key => $value) {
if (is_array($value)) {
_patterns_recurse_tokens($object[$key], $identifiers);
}
elseif (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));
}
}
}
}