class User_pruneSettingsForm in User Prune 8
Configure Userprune settings for this site.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\User_prune\Form\User_pruneSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of User_pruneSettingsForm
File
- src/
Form/ User_pruneSettingsForm.php, line 14 - Contains \Drupal\user_prune\Form
Namespace
Drupal\User_prune\FormView source
class User_pruneSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'Userprune_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'Userprune.settings',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['year_select'] = [
'#type' => 'select',
'#title' => $this
->t('Select Year'),
'#default_value' => \Drupal::state()
->get('year_select'),
'#options' => [
'0' => $this
->t('0 Years'),
'31556926' => $this
->t('1 Year'),
'63113852' => $this
->t('2 Years'),
'94670778' => $this
->t('3 Years'),
'126227704' => $this
->t('4 Years'),
'157784630' => $this
->t('5 Years'),
'189341556' => $this
->t('6 Years'),
'220898482' => $this
->t('7 Years'),
'252455408' => $this
->t('8 Years'),
'284012334' => $this
->t('9 Years'),
'315569260' => $this
->t('10 Years'),
],
];
$form['month_select'] = [
'#type' => 'select',
'#title' => $this
->t('Select Month'),
'#default_value' => \Drupal::state()
->get('month_select'),
'#options' => [
'0' => $this
->t('0 Months'),
'2629743' => $this
->t('1 Month'),
'5259486' => $this
->t('2 Months'),
'7889229' => $this
->t('3 Months'),
'10518972' => $this
->t('4 Months'),
'13148715' => $this
->t('5 Months'),
'15778458' => $this
->t('6 Months'),
'18408201' => $this
->t('7 Months'),
'21037944' => $this
->t('8 Months'),
'23667687' => $this
->t('9 Months'),
'26297430' => $this
->t('10 Months'),
'28927173' => $this
->t('11 Months'),
'31556916' => $this
->t('12 Months'),
],
];
$form['day_select'] = [
'#type' => 'select',
'#title' => $this
->t('Day Year'),
'#default_value' => \Drupal::state()
->get('day_select'),
'#options' => [
'0' => $this
->t('0 Days'),
'86400' => $this
->t('1 Day'),
'172800' => $this
->t('2 Days'),
'259200' => $this
->t('3 Days'),
'345600' => $this
->t('4 Days'),
'432000' => $this
->t('5 Days'),
'518400' => $this
->t('6 Days'),
'604800' => $this
->t('7 Days'),
'691200' => $this
->t('8 Days'),
'777600' => $this
->t('9 Days'),
'864000' => $this
->t('10 Days'),
'950400' => $this
->t('11 Days'),
'1036800' => $this
->t('12 Days'),
'1123200' => $this
->t('13 Days'),
'1209600' => $this
->t('14 Days'),
'1296000' => $this
->t('15 Days'),
'1382400' => $this
->t('16 Days'),
'1468800' => $this
->t('17 Days'),
'1555200' => $this
->t('18 Days'),
'1641600' => $this
->t('19 Days'),
'1728000' => $this
->t('20 Days'),
'1814400' => $this
->t('21 Days'),
'1900800' => $this
->t('22 Days'),
'1987200' => $this
->t('23 Days'),
'2073600' => $this
->t('24 Days'),
'2160000' => $this
->t('25 Days'),
'2246400' => $this
->t('26 Days'),
'2332800' => $this
->t('27 Days'),
'2419200' => $this
->t('28 Days'),
'2505600' => $this
->t('29 Days'),
'2592000' => $this
->t('30 Days'),
'2678400' => $this
->t('31 Days'),
],
];
$form['user_number_select'] = [
'#type' => 'select',
'#title' => $this
->t('Select the number of user to delete on cronrun'),
'#default_value' => \Drupal::state()
->get('user_number_select'),
'#options' => [
'10' => $this
->t('10'),
'25' => $this
->t('25'),
'50' => $this
->t('50'),
'75' => $this
->t('75'),
'100' => $this
->t('100'),
'200' => $this
->t('200'),
'500' => $this
->t('500'),
],
];
$form['user_status'] = array(
'#type' => 'radios',
'#title' => $this
->t('User status'),
'#default_value' => \Drupal::state()
->get('user_status'),
'#options' => array(
'all' => $this
->t('All users'),
'blocked' => $this
->t('Just the blocked users'),
'active' => $this
->t('Just the active users'),
),
);
// User never logged in.
$form['user_never_logged_in_label'] = array(
'#markup' => "<label for='logged-in'>" . t('Never logged in users') . "</div>",
);
$form['user_never_logged_in'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Delete only users who never logged in.'),
'#default_value' => \Drupal::state()
->get('user_never_logged_in'),
);
/*$form['title'] = array(
'#type' => 'item',
'#title' => $this->t('Do not delete users with roles:'),
);
$system_roles = user_roles(true);
foreach($system_roles as $system_role){
$role_id = $system_role->id();
if($role_id != 'authenticated'){
$form['roles'][$system_role->id()] = array(
'#type' => 'checkbox',
'#title' => t($system_role->id()),
'#default_value' => \Drupal::state()->get($system_role->id()),
);
}
}*/
$form['delete_users_on_cron_lable'] = array(
'#markup' => "<label for='logged-in'>" . t('On Cron') . "</div>",
);
$form['delete_users_on_cron'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Delete users on each cron run.'),
'#default_value' => \Drupal::state()
->get('delete_users_on_cron'),
);
$form['preview_button'] = array(
'#type' => 'submit',
'#value' => 'Preview',
'#submit' => array(
'preview_button_action',
),
);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($form_state
->getValues() as $key => $value) {
\Drupal::state()
->set($key, $value);
}
foreach ($form_state
->getValues() as $key => $value) {
drupal_set_message($key . ': ' . $value);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. | |
User_pruneSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
User_pruneSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
User_pruneSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
User_pruneSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |