taxonomy_menu_sync-1.0.4/src/Form/TaxonomyMenuSyncDeleteForm.php

src/Form/TaxonomyMenuSyncDeleteForm.php
<?php

namespace Drupal\taxonomy_menu_sync\Form;

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

/**
 * Delete menu configurations.
 */
class TaxonomyMenuSyncDeleteForm extends ContentEntityConfirmFormBase {

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

  /**
   * {@inheritDoc}
   */
  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.taxonomy_menu_sync.collection');
  }

  /**
   * {@inheritDoc}
   */
  public function getDescription() {
    return $this->t('Deleting this configuration will delete the menu items associated. This action cannot be undone.');
  }

  /**
   * {@inheritdoc}
   *
   * Delete the entity and log the event. logger() replaces the watchdog.
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->getEntity()->delete();
    $this->logger('taxonomy_menu_sync')->notice('Deleted %title of taxonomy menu sync.', ['%title' => $this->entity->label()]);
    $this->messenger()->addMessage($this->t('Deleted %title of taxonomy menu sync.', ['%title' => $this->entity->label()]));
    $form_state->setRedirect('entity.taxonomy_menu_sync.collection');
  }

}

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

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