function UserDevelGenerate::settingsForm
Same name in other branches
- 4.x devel_generate/src/Plugin/DevelGenerate/UserDevelGenerate.php \Drupal\devel_generate\Plugin\DevelGenerate\UserDevelGenerate::settingsForm()
Overrides DevelGenerateBase::settingsForm
File
-
devel_generate/
src/ Plugin/ DevelGenerate/ UserDevelGenerate.php, line 70
Class
- UserDevelGenerate
- Provides a UserDevelGenerate plugin.
Namespace
Drupal\devel_generate\Plugin\DevelGenerateCode
public function settingsForm(array $form, FormStateInterface $form_state) : array {
$form['num'] = [
'#type' => 'number',
'#title' => $this->t('How many users would you like to generate?'),
'#default_value' => $this->getSetting('num'),
'#required' => TRUE,
'#min' => 0,
];
$form['kill'] = [
'#type' => 'checkbox',
'#title' => $this->t('Delete all users (except user id 1) before generating new users.'),
'#default_value' => $this->getSetting('kill'),
];
$roles = array_map(static fn($role): string => $role->label(), $this->roleStorage
->loadMultiple());
unset($roles[AccountInterface::AUTHENTICATED_ROLE], $roles[AccountInterface::ANONYMOUS_ROLE]);
$form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Which roles should the users receive?'),
'#description' => $this->t('Users always receive the <em>authenticated user</em> role.'),
'#options' => $roles,
];
$form['pass'] = [
'#type' => 'textfield',
'#title' => $this->t('Password to be set'),
'#default_value' => $this->getSetting('pass'),
'#size' => 32,
'#description' => $this->t('Leave this field empty if you do not need to set a password'),
];
$options = [
1 => $this->t('Now'),
];
foreach ([
3600,
86400,
604800,
2592000,
31536000,
] as $interval) {
$options[$interval] = $this->dateFormatter
->formatInterval($interval, 1) . ' ' . $this->t('ago');
}
$form['time_range'] = [
'#type' => 'select',
'#title' => $this->t('How old should user accounts be?'),
'#description' => $this->t('User ages will be distributed randomly from the current time, back to the selected time.'),
'#options' => $options,
'#default_value' => 604800,
];
return $form;
}