public function SettingsForm::buildForm in Access unpublished 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ SettingsForm.php, line 33
Class
- SettingsForm
- Configure access unpublished settings for this site.
Namespace
Drupal\access_unpublished\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('access_unpublished.settings');
$form['hash_key'] = [
'#type' => 'textfield',
'#title' => $this
->t('Hash key'),
'#default_value' => $config
->get('hash_key'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
];
$form['duration'] = [
'#type' => 'select',
'#title' => $this
->t('Lifetime'),
'#description' => $this
->t('Default lifetime of the generated access tokens.'),
'#options' => AccessUnpublishedForm::getDurationOptions(),
'#default_value' => $config
->get('duration'),
];
$form['cleanup_expired_tokens'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Cleanup expired tokens'),
'#description' => $this
->t('Cron will cleanup expired tokens.'),
'#default_value' => $config
->get('cleanup_expired_tokens'),
];
$form['cleanup_expired_tokens_period'] = [
'#type' => 'textfield',
'#title' => $this
->t('Period of time for cron cleanup.'),
'#default_value' => $config
->get('cleanup_expired_tokens_period'),
'#description' => $this
->t("Describe a time by reference to the current day, like '-90 days' (All tokens which expired more than 90 days ago). See <a href=\"http://php.net/manual/function.strtotime.php\">strtotime</a> for more details."),
'#size' => 60,
'#maxlength' => 128,
'#states' => [
'visible' => [
':input[name="cleanup_expired_tokens"]' => [
'checked' => TRUE,
],
],
],
];
$form['modify_http_headers'] = [
'#type' => 'textarea',
'#title' => $this
->t('Modify HTTP Headers on unpublished page.'),
'#default_value' => $this
->prepareHeadersDisplay(),
'#description' => $this
->t("Enter one header per line, in the format key|label."),
'#element_validate' => [
[
ListItemBase::class,
'validateAllowedValues',
],
],
'#field_has_data' => FALSE,
];
return parent::buildForm($form, $form_state);
}