DeleteForm.php

Same filename in this branch
  1. 11.x core/modules/forum/src/Form/DeleteForm.php
Same filename in other branches
  1. 9 core/modules/forum/src/Form/DeleteForm.php
  2. 9 core/modules/comment/src/Form/DeleteForm.php
  3. 8.9.x core/modules/forum/src/Form/DeleteForm.php
  4. 8.9.x core/modules/comment/src/Form/DeleteForm.php
  5. 10 core/modules/forum/src/Form/DeleteForm.php
  6. 10 core/modules/comment/src/Form/DeleteForm.php

Namespace

Drupal\comment\Form

File

core/modules/comment/src/Form/DeleteForm.php

View source
<?php

namespace Drupal\comment\Form;

use Drupal\Core\Entity\ContentEntityDeleteForm;

/**
 * Provides the comment delete confirmation form.
 *
 * @internal
 */
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
            ->toUrl();
    }
    
    /**
     * {@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')
            ->info('Deleted comment @cid and its replies.', [
            '@cid' => $this->entity
                ->id(),
        ]);
    }

}

Classes

Title Deprecated Summary
DeleteForm Provides the comment delete confirmation form.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.