class NegotiationSessionForm
Same name and namespace in other branches
- 10 core/modules/language/src/Form/NegotiationSessionForm.php \Drupal\language\Form\NegotiationSessionForm
- 11.x core/modules/language/src/Form/NegotiationSessionForm.php \Drupal\language\Form\NegotiationSessionForm
- 8.9.x core/modules/language/src/Form/NegotiationSessionForm.php \Drupal\language\Form\NegotiationSessionForm
Configure the session language negotiation method for this site.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements \Drupal\Core\Form\FormInterface, \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses \Drupal\Core\Form\ConfigFormBaseTrait extends \Drupal\Core\Form\FormBase
- class \Drupal\language\Form\NegotiationSessionForm extends \Drupal\Core\Form\ConfigFormBase
- class \Drupal\Core\Form\ConfigFormBase uses \Drupal\Core\Form\ConfigFormBaseTrait extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of NegotiationSessionForm
1 string reference to 'NegotiationSessionForm'
- language.routing.yml in core/
modules/ language/ language.routing.yml - core/modules/language/language.routing.yml
File
-
core/
modules/ language/ src/ Form/ NegotiationSessionForm.php, line 13
Namespace
Drupal\language\FormView source
class NegotiationSessionForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'language_negotiation_configure_session_form';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'language.negotiation',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('language.negotiation');
$form['language_negotiation_session_param'] = [
'#title' => $this->t('Request/session parameter'),
'#type' => 'textfield',
'#default_value' => $config->get('session.parameter'),
'#description' => $this->t('Name of the request/session parameter used to determine the desired language.'),
];
$form_state->setRedirect('language.negotiation');
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.negotiation')
->set('session.parameter', $form_state->getValue('language_negotiation_session_param'))
->save();
parent::submitForm($form, $form_state);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.