You are here

ClientDeleteConfirmForm.php in OAuth2 Server 8

Same filename and directory in other branches
  1. 2.0.x src/Form/ClientDeleteConfirmForm.php

File

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

namespace Drupal\oauth2_server\Form;

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

/**
 * Class Client Delete Confirm Form.
 *
 * @package Drupal\oauth2_server\Form
 */
class ClientDeleteConfirmForm extends EntityConfirmFormBase {

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

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this
      ->t('Deleting a client will disable all connectivity to it.');
  }

  /**
   * {@inheritdoc}
   */
  public function getCancelUrl() {
    return new Url('entity.oauth2_server.clients', [
      'oauth2_server' => $this->entity->server_id,
    ]);
  }

  /**
   * {@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 OAuth2 server client %name has been deleted.', [
      '%name' => $this->entity
        ->label(),
    ]));
    $form_state
      ->setRedirect('entity.oauth2_server.clients', [
      'oauth2_server' => $this->entity->server_id,
    ]);
  }

}

Classes

Namesort descending Description
ClientDeleteConfirmForm Class Client Delete Confirm Form.