M4032404Form.php in 403 to 404 8
File
src/Form/M4032404Form.php
View source
<?php
namespace Drupal\m4032404\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class M4032404Form extends ConfigFormBase {
public function getFormId() {
return 'm4032404_config_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$m4032404_admin_only = $this
->config('m4032404.settings')
->get('admin_only');
$form['m4032404_admin_only'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Enforce on Admin Only'),
'#description' => $this
->t('Check the box to enforce the 404 behavior only on admin paths'),
'#default_value' => $m4032404_admin_only,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Save configuration'),
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('m4032404.settings')
->set('admin_only', $form_state
->getValue('m4032404_admin_only'))
->save();
parent::submitForm($form, $form_state);
}
public function getEditableConfigNames() {
return [
'm4032404.settings',
];
}
}