You are here

public function UserCancelForm::getDescription in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::getDescription()
  2. 9 core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::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() {
  if ($this->selectCancel) {
    return '';
  }
  $default_method = $this
    ->config('user.settings')
    ->get('cancel_method');
  $own_account = $this->entity
    ->id() == $this
    ->currentUser()
    ->id();

  // Options supplied via user_cancel_methods() can have a custom
  // #confirm_description property for the confirmation form description.
  // This text refers to "Your account" so only user it if cancelling own account.
  if ($own_account && isset($this->cancelMethods[$default_method]['#confirm_description'])) {
    return $this->cancelMethods[$default_method]['#confirm_description'];
  }
  return $this->cancelMethods['#options'][$default_method];
}