You are here

function courier_tokens in Courier 2.x

Same name and namespace in other branches
  1. 8 courier.tokens.inc \courier_tokens()

Implements hook_tokens().

File

./courier.tokens.inc, line 32
Builds tokens for Courier.

Code

function courier_tokens($type, $tokens, array $data = [], array $options = []) {
  $replacements = [];
  if ($type == 'identity' && !empty($data['identity'])) {
    if (($identity = $data['identity']) && $identity instanceof EntityInterface) {
      foreach ($tokens as $name => $original) {
        switch ($name) {
          case 'label':
            $replacements[$original] = $identity
              ->label() ?: t('Unassigned');
            break;
        }
      }
    }
  }
  return $replacements;
}