class ContactDeleteForm

Provides a form for deleting a content_entity_example entity.

Hierarchy

  • class \Drupal\content_entity_example\Form\ContactDeleteForm extends \Drupal\Core\Entity\ContentEntityConfirmFormBase

Expanded class hierarchy of ContactDeleteForm

Related topics

File

modules/content_entity_example/src/Form/ContactDeleteForm.php, line 14

Namespace

Drupal\content_entity_example\Form
View source
class ContactDeleteForm extends ContentEntityConfirmFormBase {
  
  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    return $this->t('Are you sure you want to delete entity %name?', [
      '%name' => $this->entity
        ->label(),
    ]);
  }
  
  /**
   * {@inheritdoc}
   *
   * If the delete command is canceled, return to the contact list.
   */
  public function getCancelUrl() {
    return new Url('entity.content_entity_example_contact.collection');
  }
  
  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this->t('Delete');
  }
  
  /**
   * {@inheritdoc}
   *
   * Delete the entity and log the event. logger() replaces the watchdog.
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $entity = $this->getEntity();
    $entity->delete();
    $this->logger('content_entity_example')
      ->notice('@type: deleted %title.', [
      '@type' => $this->entity
        ->bundle(),
      '%title' => $this->entity
        ->label(),
    ]);
    $form_state->setRedirect('entity.content_entity_example_contact.collection');
  }

}

Members

Title Sort descending Modifiers Object type Summary
ContactDeleteForm::getCancelUrl public function If the delete command is canceled, return to the contact list.
ContactDeleteForm::getConfirmText public function
ContactDeleteForm::getQuestion public function
ContactDeleteForm::submitForm public function Delete the entity and log the event. logger() replaces the watchdog.