FacConfigEnableConfirmForm.php in Fast Autocomplete 8
File
src/Form/FacConfigEnableConfirmForm.php
View source
<?php
namespace Drupal\fac\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class FacConfigEnableConfirmForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to enable the Fast Autocomplete configuration %name?', [
'%name' => $this->entity
->label(),
]);
}
public function getDescription() {
return $this
->t('This enables the Fast Autocomplete configuration.');
}
public function getCancelUrl() {
return new Url('entity.fac_config.collection');
}
public function getConfirmText() {
return $this
->t('Enable');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->entity;
$entity
->setStatus(TRUE)
->save();
$this
->messenger()
->addStatus($this
->t('The Fast Autocomplete configuration %name has been enabled.', [
'%name' => $entity
->label(),
]));
$form_state
->setRedirect('entity.fac_config.collection');
}
}