You are here

function logintoboggan_tokens in LoginToboggan 8

Same name and namespace in other branches
  1. 7 logintoboggan.tokens.inc \logintoboggan_tokens()

Implements hook_tokens().

File

./logintoboggan.tokens.inc, line 24
Builds placeholder replacement tokens for logintoboggan-related data.

Code

function logintoboggan_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  $url_options = array(
    'absolute' => TRUE,
  );
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
  }
  if ($type == 'user' && !empty($data['user'])) {
    $account = $data['user'];
    foreach ($tokens as $name => $original) {
      switch ($name) {

        // Validating URL.
        case 'validate-url':
          $register = Drupal::config('user.settings')
            ->get('register');
          if ($register == 'visitors') {
            $replacements[$original] = LogintobogganUtility::emlValidateUrl($account, $url_options);
          }
          break;
      }
    }
  }
  return $replacements;
}