function registration_tokens in Entity Registration 8.2
Same name and namespace in other branches
- 8 registration.module \registration_tokens()
- 7.2 registration.module \registration_tokens()
- 7 registration.module \registration_tokens()
Implements hook_tokens().
File
- ./
registration.module, line 1398
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 = \Drupal::token()
->findWithPrefix($tokens, 'entity')) {
$entity = $wrapper->entity
->value();
$replacements += \Drupal::token()
->generate($registration->entity_type, $entity_tokens, array(
$registration->entity_type => $entity,
), $options);
}
if ($entity_tokens = \Drupal::token()
->findWithPrefix($tokens, 'registrant')) {
$registration_type = registration_get_types($wrapper
->type());
$registrant = $wrapper->registrant
->value();
$replacements += \Drupal::token()
->generate($registration_type->registrant_entity_type, $entity_tokens, array(
$registration_type->registrant_entity_type => $registrant,
), $options);
}
return $replacements;
}
}