DefaultSettingsForm.php in Content Translation Redirect 8
File
src/Form/DefaultSettingsForm.php
View source
<?php
namespace Drupal\content_translation_redirect\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\ConfigFormBase;
class DefaultSettingsForm extends ConfigFormBase {
use ContentTranslationRedirectFormTrait;
public function getFormId() {
return 'content_translation_redirect_settings_form';
}
protected function getEditableConfigNames() {
return [
'content_translation_redirect.default',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$default_settings = $this
->config('content_translation_redirect.default');
$settings = [
'code' => $default_settings
->get('code'),
'message' => $default_settings
->get('message'),
];
$form += $this
->redirectSettingsForm($settings, TRUE);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('content_translation_redirect.default')
->set('code', $form_state
->getValue('code'))
->set('message', $form_state
->getValue('message'))
->save();
parent::submitForm($form, $form_state);
}
}