BUEditorSettingsForm.php in BUEditor 8.2
File
src/Form/BUEditorSettingsForm.php
View source
<?php
namespace Drupal\bueditor\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class BUEditorSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'bueditor_settings_form';
}
protected function getEditableConfigNames() {
return [
'bueditor.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('bueditor.settings');
$form['devmode'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Enable development mode'),
'#default_value' => $config
->get('devmode'),
'#description' => $this
->t('In development mode minified libraries are replaced by source libraries to make debugging easier.'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('bueditor.settings');
$devmode = $form_state
->getValue('devmode');
if ($config
->get('devmode') != $devmode) {
\Drupal::cache('discovery')
->invalidate('library_info');
}
$config
->set('devmode', $devmode)
->save();
parent::submitForm($form, $form_state);
}
}