You are here

function _apigee_edge_existing_developer_email_verification_link in Apigee Edge 8

Generates an URL to confirm identity of a user with existing developer mail.

Based on user_cancel_url().

Parameters

\Drupal\user\UserInterface $account: User object.

array $options: (optional) A keyed array of settings. Supported options are:

  • langcode: A language code to be used when generating locale-sensitive URLs. If langcode is NULL the users preferred language is used.

Return value

string A unique URL that may be used to confirm the cancellation of the user account.

See also

\_apigee_edge_existing_developer_mail_tokens()

\Drupal\user\Controller\UserController::confirmCancel()

1 call to _apigee_edge_existing_developer_email_verification_link()
_apigee_edge_existing_developer_mail_tokens in ./apigee_edge.module
Token callback to add unsafe tokens for existing developer user mails.

File

./apigee_edge.module, line 975
Copyright 2018 Google Inc.

Code

function _apigee_edge_existing_developer_email_verification_link(UserInterface $account, array $options = []) {
  $languageManager = \Drupal::languageManager();
  $timestamp = \Drupal::time()
    ->getRequestTime();
  $langcode = isset($options['langcode']) ? $options['langcode'] : $account
    ->getPreferredLangcode();
  $url_options = [
    'absolute' => TRUE,
    'language' => $languageManager
      ->getLanguage($langcode),
  ];
  $url_options['query'][\Drupal::config('apigee_edge.developer_settings')
    ->get('verification_token')] = apigee_edge_existing_developer_registration_hash($account, $timestamp);
  $url_options['query']['timestamp'] = $timestamp;

  // For now, use this method for generating url to the user register and
  // edit forms.
  $route = 'user.register';
  $route_params = [];
  if (!$account
    ->isAnonymous()) {
    $route = 'entity.user.edit_form';
    $route_params['user'] = $account
      ->id();
  }
  return Url::fromRoute($route, $route_params, $url_options)
    ->toString();
}