class AdminBlockDeleteForm

Provides a deletion confirmation form for the block instance deletion form.

Hierarchy

Expanded class hierarchy of AdminBlockDeleteForm

1 string reference to 'AdminBlockDeleteForm'
block.routing.yml in drupal/core/modules/block/block.routing.yml
drupal/core/modules/block/block.routing.yml

File

drupal/core/modules/block/lib/Drupal/block/Form/AdminBlockDeleteForm.php, line 16
Contains \Drupal\block\Form\AdminBlockDeleteForm.

Namespace

Drupal\block\Form
View source
class AdminBlockDeleteForm extends ConfirmFormBase {

  /**
   * The block being deleted.
   *
   * @var \Drupal\block\Plugin\Core\Entity\Block
   */
  protected $block;

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

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

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

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

  /**
   * Implements \Drupal\Core\Form\FormInterface::buildForm().
   *
   * @param \Drupal\block\Plugin\Core\Entity\Block $block
   *   The block instance.
   */
  public function buildForm(array $form, array &$form_state, Block $block = null) {
    $this->block = $block;
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->block
      ->delete();
    drupal_set_message(t('The block %name has been removed.', array(
      '%name' => $this->block
        ->label(),
    )));
    $form_state['redirect'] = 'admin/structure/block';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminBlockDeleteForm::$block protected property The block being deleted.
AdminBlockDeleteForm::buildForm public function Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides ConfirmFormBase::buildForm
AdminBlockDeleteForm::getCancelPath protected function Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase::getCancelPath
AdminBlockDeleteForm::getConfirmText protected function Returns a caption for the button that confirms the action. Overrides ConfirmFormBase::getConfirmText
AdminBlockDeleteForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
AdminBlockDeleteForm::getQuestion protected function Returns the question to ask the user. Overrides ConfirmFormBase::getQuestion
AdminBlockDeleteForm::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