You are here

EntityExportCsvDisableForm.php in Entity Export CSV 8

File

src/Form/EntityExportCsvDisableForm.php
View source
<?php

namespace Drupal\entity_export_csv\Form;

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

/**
 * Class EntityExportCsvDisableForm.
 *
 * @package Drupal\entity_export_csv\Form
 */
class EntityExportCsvDisableForm extends EntityConfirmFormBase {

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this
      ->t('Disable @type: %label?', [
      '@type' => $this->entity
        ->getEntityType()
        ->getLabel(),
      '%label' => $this->entity
        ->label(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this
      ->t('Disable @type: %label?', [
      '@type' => $this->entity
        ->getEntityType()
        ->getLabel(),
      '%label' => $this->entity
        ->label(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    $type = $this->entity
      ->getEntityType()
      ->get('id');
    return new Url("entity.{$type}.collection");
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
    $entity = $this->entity;
    $entity
      ->disable()
      ->save();
    Drupal::logger('entity_export_csv')
      ->notice('%type configuration %id disabled', [
      '%type' => $entity
        ->get('entityTypeId'),
      '%id' => $entity
        ->id(),
    ]);
    parent::submitForm($form, $form_state);
    $form_state
      ->setRedirectUrl($this
      ->getCancelUrl());
  }

}

Classes

Namesort descending Description
EntityExportCsvDisableForm Class EntityExportCsvDisableForm.