t('Are you sure you want to delete the @entity-type %label?', array( '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), '%label' => $this->getEntity()->label(), )); } /** * {@inheritdoc} */ public function getConfirmText() { return $this->t('Delete'); } /** * Returns the message to display to the user after deleting the entity. * * @return string * The translated string of the deletion message. */ protected function getDeletionMessage() { $entity = $this->getEntity(); return $this->t('The @entity-type %label has been deleted.', array( '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), '%label' => $entity->label(), )); } /** * {@inheritdoc} */ public function getCancelUrl() { $entity = $this->getEntity(); if ($entity->hasLinkTemplate('collection')) { // If available, return the collection URL. return $entity->urlInfo('collection'); } else { // Otherwise fall back to the default link template. return $entity->urlInfo(); } } /** * Logs a message about the deleted entity. */ protected function logDeletionMessage() { $entity = $this->getEntity(); $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', array( '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), '%label' => $entity->label(), )); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->getEntity()->delete(); drupal_set_message($this->getDeletionMessage()); $form_state->setRedirectUrl($this->getCancelUrl()); $this->logDeletionMessage(); } }