Settings.php in DRD Agent 8.3
File
src/Form/Settings.php
View source
<?php
namespace Drupal\drd_agent\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class Settings extends ConfigFormBase {
public function getFormId() : string {
return 'drd_agent_settings_form';
}
protected function getEditableConfigNames() : array {
return [
'drd_agent.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) : array {
$config = $this
->config('drd_agent.settings');
$form['debug_mode'] = [
'#type' => 'checkbox',
'#title' => t('Debug mode'),
'#default_value' => $config
->get('debug_mode'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->configFactory()
->getEditable('drd_agent.settings');
$form_state
->cleanValues();
foreach ($form_state
->getValues() as $key => $value) {
$config
->set($key, $value);
}
$config
->save();
parent::submitForm($form, $form_state);
}
}
Classes
Name |
Description |
Settings |
Configure drd-agent settings for this site. |