You are here

function redhen_contact_tokens in RedHen CRM 8

Implements hook_tokens().

File

modules/redhen_contact/redhen_contact.module, line 98
Contains redhen_contact.module..

Code

function redhen_contact_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];
  if ($type == 'entity' && isset($data['entity_type']) && $data['entity_type'] == 'redhen_contact') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'id':
          $replacements[$original] = $data['entity']
            ->id();
          break;
        case 'name':
          $replacements[$original] = $data['entity']
            ->getFullName();
          break;
        case 'type':
          $replacements[$original] = $data['entity']
            ->getType();
          break;
        case 'status':
          $replacements[$original] = $data['entity']
            ->isActive();
          break;
        case 'created':
          $replacements[$original] = $data['entity']
            ->getCreatedTime();
          break;
      }
    }
  }
  return $replacements;
}