MassPasswordResetConfirmForm.php in Mass Password Reset 2.x
File
src/Form/MassPasswordResetConfirmForm.php
View source
<?php
namespace Drupal\mass_pwreset\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class MassPasswordResetConfirmForm extends ConfirmFormBase {
private $batchData = array();
public function __construct() {
$tempstore = \Drupal::service('tempstore.private')
->get('mass_pwreset');
$this->batchData = $tempstore
->get('batch_data');
}
public function getFormId() {
return 'mass_pwreset_confirm_form';
}
public function getQuestion() {
return $this
->t('Confirm password resets?');
}
public function getDescription() {
return $this
->t('Are you sure you want to reset the passwords for the roles you selected? This action cannot be undone!');
}
public function getConfirmText() {
return $this
->t('Reset Passwords');
}
public function getCancelText() {
return $this
->t('Cancel');
}
public function getCancelUrl() {
return new Url('mass_pwreset.admin');
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['roles'] = [
'#theme' => 'item_list',
'#title' => t('Selected Roles'),
'#items' => $this->batchData['roles'],
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
mass_pwreset_multiple_reset($this->batchData);
}
}