class DeleteForm

Builds the form to delete a contact category.

Hierarchy

Expanded class hierarchy of DeleteForm

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

File

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

Namespace

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

  /**
   * The contact category being deleted.
   *
   * @var \Drupal\contact\Plugin\Core\Entity\Category
   */
  protected $contactCategory;

  /**
   * Implements \Drupal\Core\Form\FormInterface::getFormID().
   */
  public function getFormID() {
    return 'contact_category_delete_form';
  }

  /**
   * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion().
   */
  protected function getQuestion() {
    return t('Are you sure you want to delete %name?', array(
      '%name' => $this->contactCategory
        ->label(),
    ));
  }

  /**
   * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath().
   */
  protected function getCancelPath() {
    return 'admin/structure/contact';
  }

  /**
   * Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText().
   */
  protected function getConfirmText() {
    return t('Delete');
  }

  /**
   * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm().
   */
  public function buildForm(array $form, array &$form_state, Category $contact_category = NULL) {
    $this->contactCategory = $contact_category;
    return parent::buildForm($form, $form_state);
  }

  /**
   * Implements \Drupal\Core\Form\FormInterface::submitForm().
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->contactCategory
      ->delete();
    drupal_set_message(t('Category %label has been deleted.', array(
      '%label' => $this->contactCategory
        ->label(),
    )));
    watchdog('contact', 'Category %label has been deleted.', array(
      '%label' => $this->contactCategory
        ->label(),
    ), WATCHDOG_NOTICE);
    $form_state['redirect'] = 'admin/structure/contact';
  }

}

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::$contactCategory protected property The contact category being deleted.
DeleteForm::buildForm public function Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). Overrides ConfirmFormBase::buildForm
DeleteForm::getCancelPath protected function Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). Overrides ConfirmFormBase::getCancelPath
DeleteForm::getConfirmText protected function Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). Overrides ConfirmFormBase::getConfirmText
DeleteForm::getFormID public function Implements \Drupal\Core\Form\FormInterface::getFormID(). Overrides FormInterface::getFormID
DeleteForm::getQuestion protected function Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). Overrides ConfirmFormBase::getQuestion
DeleteForm::submitForm public function Implements \Drupal\Core\Form\FormInterface::submitForm(). Overrides FormInterface::submitForm