You are here

function invite_by_email_tokens in Invite 8

Implements hook_tokens().

File

modules/invite_by_email/invite_by_email.tokens.inc, line 39
Invite tokens.

Code

function invite_by_email_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = [];
  if ($type == 'invite') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'inviter:name':
          $replacements[$original] = $data['invite']
            ->getOwner()
            ->getAccountName();
          break;
        case 'invite-accept-link':
          $replacements[$original] = Link::createFromRoute('accept invite', 'invite.invite_accept_accept', [
            'invite' => $data['invite']
              ->getRegCode(),
          ], [
            'absolute' => TRUE,
          ])
            ->getUrl()
            ->toString();
          break;
        default:
      }
    }
  }
  return $replacements;
}