class NegotiationBrowserDeleteForm
Same name and namespace in other branches
- 10 core/modules/language/src/Form/NegotiationBrowserDeleteForm.php \Drupal\language\Form\NegotiationBrowserDeleteForm
- 11.x core/modules/language/src/Form/NegotiationBrowserDeleteForm.php \Drupal\language\Form\NegotiationBrowserDeleteForm
- 8.9.x core/modules/language/src/Form/NegotiationBrowserDeleteForm.php \Drupal\language\Form\NegotiationBrowserDeleteForm
Defines a confirmation form for deleting a browser language negotiation mapping.
@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\ConfirmFormBase implements \Drupal\Core\Form\ConfirmFormInterface extends \Drupal\Core\Form\FormBase
- class \Drupal\language\Form\NegotiationBrowserDeleteForm uses \Drupal\Core\Form\ConfigFormBaseTrait extends \Drupal\Core\Form\ConfirmFormBase
- class \Drupal\Core\Form\ConfirmFormBase implements \Drupal\Core\Form\ConfirmFormInterface extends \Drupal\Core\Form\FormBase
Expanded class hierarchy of NegotiationBrowserDeleteForm
1 string reference to 'NegotiationBrowserDeleteForm'
- language.routing.yml in core/
modules/ language/ language.routing.yml - core/modules/language/language.routing.yml
File
-
core/
modules/ language/ src/ Form/ NegotiationBrowserDeleteForm.php, line 15
Namespace
Drupal\language\FormView source
class NegotiationBrowserDeleteForm extends ConfirmFormBase {
use ConfigFormBaseTrait;
/**
* The browser language code to be deleted.
*
* @var string
*/
protected $browserLangcode;
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'language.mappings',
];
}
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete %browser_langcode?', [
'%browser_langcode' => $this->browserLangcode,
]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('language.negotiation_browser');
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'language_negotiation_configure_browser_delete_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $browser_langcode = NULL) {
$this->browserLangcode = $browser_langcode;
$form = parent::buildForm($form, $form_state);
return $form;
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.mappings')
->clear('map.' . $this->browserLangcode)
->save();
$args = [
'%browser' => $this->browserLangcode,
];
$this->logger('language')
->notice('The browser language detection mapping for the %browser browser language code has been deleted.', $args);
$this->messenger()
->addStatus($this->t('The mapping for the %browser browser language code has been deleted.', $args));
$form_state->setRedirect('language.negotiation_browser');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.