SettingsForm.php in Lightning API 8.4
File
src/Form/SettingsForm.php
View source
<?php
namespace Drupal\lightning_api\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class SettingsForm extends ConfigFormBase {
protected function getEditableConfigNames() {
return [
'lightning_api.settings',
];
}
public function getFormId() {
return 'lightning_api_settings_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('lightning_api.settings');
$form['entity_json'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Expose a "View JSON" link in entity operations'),
'#default_value' => $config
->get('entity_json'),
];
$form['bundle_docs'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Expose a "View API Documentation" link in bundle entity operations'),
'#default_value' => $config
->get('bundle_docs'),
];
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('lightning_api.settings')
->set('entity_json', (bool) $form_state
->getValue('entity_json'))
->set('bundle_docs', (bool) $form_state
->getValue('bundle_docs'))
->save();
parent::submitForm($form, $form_state);
}
}
Classes
Name |
Description |
SettingsForm |
The settings form for controlling Content API's behavior. |