sites_group_overrides-1.x-dev/modules/sites_group_masquerade/src/Form/SettingsForm.php
modules/sites_group_masquerade/src/Form/SettingsForm.php
<?php
declare(strict_types=1);
namespace Drupal\sites_group_masquerade\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Configure Sites group masquerade settings.
*/
final class SettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId(): string {
return 'sites_group_masquerade_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames(): array {
return ['sites_group_masquerade.settings'];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state): array {
$form['automasquerade'] = [
'#type' => 'checkbox',
'#title' => $this->t('Auto site-masquerade based on a group paratmeter in the URL'),
'#default_value' => $this->config('sites_group_masquerade.settings')->get('automasquerade') ?? FALSE,
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state): void {
$this->config('sites_group_masquerade.settings')
->set('automasquerade', boolval($form_state->getValue('automasquerade')))
->save();
parent::submitForm($form, $form_state);
}
}
