public function SiteMaintenanceModeForm::buildForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/src/Form/SiteMaintenanceModeForm.php \Drupal\system\Form\SiteMaintenanceModeForm::buildForm()
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
- core/
modules/ system/ src/ Form/ SiteMaintenanceModeForm.php, line 78
Class
- SiteMaintenanceModeForm
- Configure maintenance settings for this site.
Namespace
Drupal\system\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('system.maintenance');
$permissions = $this->permissionHandler
->getPermissions();
$permission_label = $permissions['access site in maintenance mode']['title'];
$form['maintenance_mode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Put site into maintenance mode'),
'#default_value' => $this->state
->get('system.maintenance_mode'),
'#description' => $this
->t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', [
'@permission-label' => $permission_label,
':permissions-url' => Url::fromRoute('user.admin_permissions')
->toString(),
':user-login' => Url::fromRoute('user.login')
->toString(),
]),
];
$form['maintenance_mode_message'] = [
'#type' => 'textarea',
'#title' => $this
->t('Message to display when in maintenance mode'),
'#default_value' => $config
->get('message'),
];
return parent::buildForm($form, $form_state);
}