EasyMetaConfigurationForm.php in Easymeta 8
File
src/Form/EasyMetaConfigurationForm.php
View source
<?php
namespace Drupal\easymeta\Form;
use Drupal\Core\Form\ConfigFormBase;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Form\FormStateInterface;
class EasyMetaConfigurationForm extends ConfigFormBase {
public function getFormId() {
return 'easymeta_admin_settings';
}
protected function getEditableConfigNames() {
return [
'easymeta.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$config = $this
->config('easymeta.settings');
$form['use_og_meta'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Use OG meta'),
'#default_value' => $config
->get('use_og_meta'),
);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$this
->config('easymeta.settings')
->set('use_og_meta', $values['use_og_meta'])
->save();
}
}