function registration_tokens in Entity Registration 7
Same name and namespace in other branches
- 8.2 registration.module \registration_tokens()
- 8 registration.module \registration_tokens()
- 7.2 registration.module \registration_tokens()
Implements hook_tokens().
File
- ./
registration.module, line 1420
Code
function registration_tokens($type, $tokens, array $data = array(), array $options = array()) {
if ($type == 'registration' && !empty($data['registration'])) {
$registration = $data['registration'];
$wrapper = entity_metadata_wrapper('registration', $data['registration']);
$replacements = array();
if ($entity_tokens = token_find_with_prefix($tokens, 'entity')) {
$entity = $wrapper->entity
->value();
$replacements += token_generate($registration->entity_type, $entity_tokens, array(
$registration->entity_type => $entity,
), $options);
}
if ($entity_tokens = token_find_with_prefix($tokens, 'user')) {
$entity = $wrapper->user
->value();
$replacements += token_generate('user', $entity_tokens, array(
'user' => $entity,
), $options);
}
return $replacements;
}
}