SensorDeleteForm.php in Monitoring 8
Contains \Drupal\monitoring\Form\SensorDeleteForm.
Namespace
Drupal\monitoring\FormFile
src/Form/SensorDeleteForm.phpView source
<?php
/**
* @file
* Contains \Drupal\monitoring\Form\SensorDeleteForm.
*/
namespace Drupal\monitoring\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
/**
* Builds the form to delete a monitoring sensor.
*/
class SensorDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return $this
->t('Are you sure you want to delete %name sensor?', array(
'%name' => $this->entity
->label(),
));
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
return new Url('monitoring.sensors_overview_settings');
}
/**
* {@inheritdoc}
*/
public function getConfirmText() {
return $this
->t('Delete');
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->delete();
$this
->messenger()
->addMessage(t('Sensor %label has been deleted.', array(
'%label' => $this->entity
->label(),
)));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}
Classes
Name | Description |
---|---|
SensorDeleteForm | Builds the form to delete a monitoring sensor. |