diff --cc core/modules/comment/comment.admin.inc index 4e81b24,4bbff56..0000000 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc diff --cc core/modules/comment/comment.routing.yml index 4ef9e0b,7768cd0..0000000 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@@ -19,17 -19,9 +19,24 @@@ comment_permalink _controller: '\Drupal\comment\Controller\CommentController::commentPermalink' requirements: _entity_access: 'comment.view' + + comment_confirm_delete: + pattern: '/comment/{comment}/delete' + defaults: + _entity_form: 'comment.delete' + requirements: + _entity_access: 'comment.delete' ++ +comment_overview_bundles: + pattern: '/admin/structure/comments' + defaults: + _content: 'Drupal\comment\Controller\AdminController::overviewBundles' + requirements: + _permission: 'administer comments' + +comment_bundle: + pattern: '/admin/structure/comments/manage/{field_name}' + defaults: + _content: 'Drupal\comment\Controller\AdminController::bundleInfo' + requirements: + _permission: 'administer comments' diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 0bd3710..d3d2d25 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -43,6 +43,22 @@ public function __construct(FieldInfo $field_info, EntityManager $entity_manager } /** + * Utility function to return URI of the comment's parent entity. + * + * @param \Drupal\comment\CommentInterface $comment + * The comment entity. + * + * @return array + * An array returned by \Drupal\Core\Entity\EntityInterface::uri(). + */ + public function getParentEntityUri(CommentInterface $comment) { + return $this->entityManager + ->getStorageController($comment->entity_type->value) + ->load($comment->entity_id->value) + ->uri(); + } + + /** * Utility function to return an array of comment fields. * * @param string $entity_type diff --git a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php index fd86ddf..69f7609 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php @@ -9,6 +9,8 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityNGConfirmFormBase; +use Drupal\comment\CommentManager; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -17,6 +19,32 @@ class DeleteForm extends EntityNGConfirmFormBase { /** + * The comment manager. + * + * @var \Drupal\comment\CommentManager + */ + protected $commentManager; + + /** + * Constructs a DeleteForm object. + * + * @param \Drupal\comment\CommentManager $comment_manager + * The comment manager service. + */ + public function __construct(CommentManager $comment_manager) { + $this->commentManager = $comment_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('comment.manager') + ); + } + + /** * {@inheritdoc} */ public function getQuestion() { @@ -27,7 +55,8 @@ public function getQuestion() { * {@inheritdoc} */ public function getCancelPath() { - return 'node/' . $this->entity->nid->target_id; + $uri = $this->commentManager->getParentEntityUri($this->entity); + return $uri['path']; } /** @@ -55,7 +84,8 @@ public function submit(array $form, array &$form_state) { // Clear the cache so an anonymous user sees that his comment was deleted. Cache::invalidateTags(array('content' => TRUE)); - $form_state['redirect'] = "node/{$this->entity->nid->target_id}"; + $uri = $this->commentManager->getParentEntityUri($this->entity); + $form_state['redirect'] = $uri['path']; } }