monitoring-8.x-1.x-dev/modules/multigraph/src/Form/MultigraphDeleteForm.php

modules/multigraph/src/Form/MultigraphDeleteForm.php
<?php

/**
 * @file
 * Contains \Drupal\monitoring_multigraph\Form\MultigraphDeleteForm.
 */

namespace Drupal\monitoring_multigraph\Form;

use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Builds the form to delete a monitoring multigraph.
 */
class MultigraphDeleteForm extends EntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this->t(
      'Are you sure you want to delete the %name multigraph?',
      array('%name' => $this->entity->label())
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this->t('Delete');
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity->delete();
    $this->messenger()->addMessage($this->t(
      'The %label multigraph has been deleted.',
      array('%label' => $this->entity->label())
    ));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

  /**
   * Returns the route to go to if the user cancels the action.
   *
   * @return \Drupal\Core\Url
   *   A URL object.
   */
  public function getCancelUrl() {
    return new Url('entity.monitoring_multigraph.list');
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc