You are here

AdminActionConfirm.php in Calendar Systems 8.2

Contains Drupal\CalendarSystems\Form\AdminSettings.

File

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

/**
 * @file
 * Contains Drupal\CalendarSystems\Form\AdminSettings.
 */
namespace Drupal\calendar_systems\Form;

use Drupal\calendar_systems\Helpers;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Url;
class AdminActionConfirm extends ConfirmFormBase {

  /**
   * ID of the item to delete.
   *
   * @var int
   */
  protected $id;

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, string $id = NULL) {
    $this->id = $id;
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $profiles = Helpers::calendar_systems_profiles();
    if (isset($profiles[$this->id])) {
      unset($profiles[$this->id]);
    }
    Helpers::calendar_systems_profiles_update($profiles);
    $form_state
      ->setRedirect('calendar_systems.admin');
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() : string {
    return "confirm_delete_form";
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('calendar_systems.admin');
  }

  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return t('Do you want to delete settings for %id?', [
      '%id' => $this->id,
    ]);
  }

}

Classes

Namesort descending Description
AdminActionConfirm