function OneTimeAuthentication::generateCancelConfirmUrl

Same name and namespace in other branches
  1. 11.x core/modules/user/src/OneTimeAuthentication.php \Drupal\user\OneTimeAuthentication::generateCancelConfirmUrl()

Generates a URL to confirm an account cancellation request.

Parameters

\Drupal\user\UserInterface $account: The user account 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.

See also

::tokens()

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

File

core/modules/user/src/OneTimeAuthentication.php, line 127

Class

OneTimeAuthentication
Generate and verify one time authentication codes.

Namespace

Drupal\user

Code

public function generateCancelConfirmUrl(UserInterface $account, array $options = []) : Url {
  $timestamp = $this->time
    ->getRequestTime();
  $langcode = $options['langcode'] ?? $account->getPreferredLangcode();
  return Url::fromRoute('user.cancel_confirm', [
    'user' => $account->id(),
    'timestamp' => $timestamp,
    'hashed_pass' => $this->generateHmac($account, $timestamp),
  ], [
    'absolute' => TRUE,
    'language' => $this->languageManager
      ->getLanguage($langcode),
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.