class ConfigTestDeleteForm

Delete confirmation form for config_test entities.

Hierarchy

Expanded class hierarchy of ConfigTestDeleteForm

1 string reference to 'ConfigTestDeleteForm'
config_test.routing.yml in drupal/core/modules/config/tests/config_test/config_test.routing.yml
drupal/core/modules/config/tests/config_test/config_test.routing.yml

File

drupal/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php, line 16
Contains \Drupal\config_test\Form\ConfigTestDeleteForm.

Namespace

Drupal\config_test\Form
View source
class ConfigTestDeleteForm extends ConfirmFormBase {

  /**
   * The config_test entity to be deleted.
   *
   * @var \Drupal\config_test\Plugin\Core\Entity\ConfigTest.
   */
  protected $configTest;

  /**
   * {@inheritdoc}
   */
  protected function getQuestion() {
    return t('Are you sure you want to delete %label', array(
      '%label' => $this->configTest
        ->label(),
    ));
  }

  /**
   * {@inheritdoc}
   */
  protected function getConfirmText() {
    return t('Delete');
  }

  /**
   * {@inheritdoc}
   */
  protected function getCancelPath() {
    return 'admin/structure/config_test';
  }

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'config_test_delete_form';
  }

  /**
   * Implements \Drupal\Drupal\Core\Form\ConfirmFormBase::buildForm().
   *
   * @param \Drupal\config_test\ConfigTestInterface $config_test
   *   (optional) The ConfigTestInterface object to delete.
   */
  public function buildForm(array $form, array &$form_state, ConfigTestInterface $config_test = NULL) {
    $this->configTest = $config_test;
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->configTest
      ->delete();
    drupal_set_message(String::format('%label configuration has been deleted.', array(
      '%label' => $this->configTest
        ->label(),
    )));
    $form_state['redirect'] = 'admin/structure/config_test';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigTestDeleteForm::$configTest protected property The config_test entity to be deleted.
ConfigTestDeleteForm::buildForm public function Implements \Drupal\Drupal\Core\Form\ConfirmFormBase::buildForm(). Overrides ConfirmFormBase::buildForm
ConfigTestDeleteForm::getCancelPath protected function Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase::getCancelPath
ConfigTestDeleteForm::getConfirmText protected function Returns a caption for the button that confirms the action. Overrides ConfirmFormBase::getConfirmText
ConfigTestDeleteForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
ConfigTestDeleteForm::getQuestion protected function Returns the question to ask the user. Overrides ConfirmFormBase::getQuestion
ConfigTestDeleteForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm
ConfirmFormBase::getCancelText protected function Returns a caption for the link which cancels the action. 2
ConfirmFormBase::getDescription protected function Returns additional text to display as a description. 10
ConfirmFormBase::getFormName protected function Returns the internal name used to refer to the confirmation item.
ConfirmFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 1