function UserCancelForm::getDescription

Same name and namespace in other branches
  1. 9 core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::getDescription()
  2. 8.9.x core/modules/user/src/Form/UserCancelForm.php \Drupal\user\Form\UserCancelForm::getDescription()
  3. 10 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() {
    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];
}

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