vais_promos-1.0.0-beta2/src/Form/VaisPromoDeleteForm.php

src/Form/VaisPromoDeleteForm.php
<?php

namespace Drupal\vais_promos\Form;

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

/**
 * Provides a form for deleting a vais_promo entity.
 *
 * @ingroup vais_promos
 */
class VaisPromoDeleteForm extends ContentEntityConfirmFormBase {

  /**
   * Returns the question to ask the user.
   *
   * @return string
   *   The form question. The page title will be set to this value.
   */
  public function getQuestion() {
    return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]);
  }

  /**
   * 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.vais_promo.collection');
  }

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

  /**
   * {@inheritdoc}
   *
   * Delete the entity and log the event. logger() replaces the watchdog.
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $entity = $this->getEntity();
    $entity->delete();

    $this->logger('vais_promo')->notice('deleted %title.',
      [
        '%title' => $this->entity->label(),
      ]);
    // Redirect to term list after delete.
    $form_state->setRedirect('entity.vais_promo.collection');
  }

}

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

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