Version 1
[yaffs-website] / web / core / modules / comment / src / Form / DeleteForm.php
diff --git a/web/core/modules/comment/src/Form/DeleteForm.php b/web/core/modules/comment/src/Form/DeleteForm.php
new file mode 100644 (file)
index 0000000..fa7ab9d
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace Drupal\comment\Form;
+
+use Drupal\Core\Entity\ContentEntityDeleteForm;
+
+/**
+ * Provides the comment delete confirmation form.
+ */
+class DeleteForm extends ContentEntityDeleteForm {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCancelUrl() {
+    // Point to the entity of which this comment is a reply.
+    return $this->entity->get('entity_id')->entity->urlInfo();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getRedirectUrl() {
+    return $this->getCancelUrl();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getDescription() {
+    return $this->t('Any replies to this comment will be lost. This action cannot be undone.');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getDeletionMessage() {
+    return $this->t('The comment and all its replies have been deleted.');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function logDeletionMessage() {
+    $this->logger('comment')->notice('Deleted comment @cid and its replies.', ['@cid' => $this->entity->id()]);
+  }
+
+}