function UserCancelForm::getDescription

Same name and namespace in other branches
  1. 11.x core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::getDescription()
  2. 10 core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::getDescription()
  3. 9 core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::getDescription()

Overrides ContentEntityConfirmFormBase::getDescription

File

core/modules/user/src/Form/UserCancelForm.php, line 56

Class

UserCancelForm
Provides a confirmation form for cancelling user account.

Namespace

Drupal\user\Form

Code

public function getDescription() {
  $description = '';
  $default_method = $this->config('user.settings')
    ->get('cancel_method');
  $own_account = $this->entity
    ->id() == $this->currentUser()
    ->id();
  if ($this->selectCancel) {
    $description = $this->t('Select the method to cancel the account above.');
  }
  elseif ($own_account && isset($this->cancelMethods[$default_method]['#confirm_description'])) {
    $description = $this->cancelMethods[$default_method]['#confirm_description'];
  }
  else {
    $description = $this->cancelMethods['#options'][$default_method];
  }
  return $description . ' ' . $this->t('This action cannot be undone.');
}

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