Provides a deletion confirmation form for Role entity.
Expanded class hierarchy of UserRoleDelete
class UserRoleDelete extends ConfirmFormBase {
/**
* The role being deleted.
*
* @var \Drupal\user\RoleInterface
*/
protected $role;
/**
* {@inheritdoc}
*/
public function getFormID() {
return 'user_admin_role_delete_confirm';
}
/**
* {@inheritdoc}
*/
protected function getQuestion() {
return t('Are you sure you want to delete the role %name?', array(
'%name' => $this->role
->label(),
));
}
/**
* {@inheritdoc}
*/
protected function getCancelPath() {
return 'admin/people/roles';
}
/**
* {@inheritdoc}
*/
protected function getConfirmText() {
return t('Delete');
}
/**
* {@inheritdoc}
* @param \Drupal\user\RoleInterface $user_role
* The role being deleted.
*/
public function buildForm(array $form, array &$form_state, RoleInterface $user_role = NULL) {
$this->role = $user_role;
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
$this->role
->delete();
watchdog('user', 'Role %name has been deleted.', array(
'%name' => $this->role
->label(),
));
drupal_set_message(t('Role %name has been deleted.', array(
'%name' => $this->role
->label(),
)));
$form_state['redirect'] = 'admin/people/roles';
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfirmFormBase:: |
protected | function | Returns a caption for the link which cancels the action. | 2 |
ConfirmFormBase:: |
protected | function | Returns additional text to display as a description. | 10 |
ConfirmFormBase:: |
protected | function | Returns the internal name used to refer to the confirmation item. | |
ConfirmFormBase:: |
public | function |
Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface:: |
1 |
UserRoleDelete:: |
protected | property | The role being deleted. | |
UserRoleDelete:: |
public | function |
Overrides ConfirmFormBase:: |
|
UserRoleDelete:: |
protected | function |
Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase:: |
|
UserRoleDelete:: |
protected | function |
Returns a caption for the button that confirms the action. Overrides ConfirmFormBase:: |
|
UserRoleDelete:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
UserRoleDelete:: |
protected | function |
Returns the question to ask the user. Overrides ConfirmFormBase:: |
|
UserRoleDelete:: |
public | function |
Form submission handler. Overrides FormInterface:: |