class DeleteForm

Builds the form to delete a forum term.

Hierarchy

Expanded class hierarchy of DeleteForm

1 string reference to 'DeleteForm'
forum.routing.yml in drupal/core/modules/forum/forum.routing.yml
drupal/core/modules/forum/forum.routing.yml

File

drupal/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php, line 16
Contains \Drupal\forum\Form\DeleteForm.

Namespace

Drupal\forum\Form
View source
class DeleteForm extends ConfirmFormBase {

  /**
   * The taxonomy term being deleted.
   *
   * @var \Drupal\taxonomy\Plugin\Core\Entity\Term
   */
  protected $taxonomyTerm;

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

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

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

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

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL) {
    $this->taxonomyTerm = $taxonomy_term;
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->taxonomyTerm
      ->delete();
    drupal_set_message(t('The forum %label and all sub-forums have been deleted.', array(
      '%label' => $this->taxonomyTerm
        ->label(),
    )));
    watchdog('forum', 'forum: deleted %label and all its sub-forums.', array(
      '%label' => $this->taxonomyTerm
        ->label(),
    ), WATCHDOG_NOTICE);
    $form_state['redirect'] = 'admin/structure/forum';
  }

}

Members

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