CheckDisableForm.php in Production check & Production monitor 8
File
src/Form/CheckDisableForm.php
View source
<?php
namespace Drupal\prod_check\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class CheckDisableForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to disable the production check %check?', [
'%check' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return new Url('entity.prod_check.collection');
}
public function getConfirmText() {
return $this
->t('Disable');
}
public function getDescription() {
return $this
->t('Disable this production check.');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->disable()
->save();
$this
->messenger()
->addMessage($this
->t('Disabled production check %check.', [
'%check' => $this->entity
->label(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}