CaptchaPointDisableForm.php in CAPTCHA 8
File
src/Form/CaptchaPointDisableForm.php
View source
<?php
namespace Drupal\captcha\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class CaptchaPointDisableForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to disable the Captcha?');
}
public function getDescription() {
return $this
->t('This will disable the captcha.');
}
public function getCancelUrl() {
return new Url('captcha_point.list');
}
public function getConfirmText() {
return $this
->t('Disable');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->disable();
$this->entity
->save();
$this
->messenger()
->addMessage($this
->t('Captcha point %label has been disabled.', [
'%label' => $this->entity
->label(),
]));
$form_state
->setRedirect('captcha_point.list');
}
}