Namespace
Drupal\content_entity_example\Form
File
-
modules/content_entity_example/src/Form/ContactDeleteForm.php
View source
<?php
namespace Drupal\content_entity_example\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class ContactDeleteForm extends ContentEntityConfirmFormBase {
public function getQuestion() {
return $this->t('Are you sure you want to delete entity %name?', [
'%name' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return new Url('entity.content_entity_example_contact.collection');
}
public function getConfirmText() {
return $this->t('Delete');
}
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');
}
}
Classes
| Title |
Deprecated |
Summary |
| ContactDeleteForm |
|
Provides a form for deleting a content_entity_example entity. |