diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentPermalinkFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentPermalinkFormatter.php index 5e22475..711835f 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentPermalinkFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentPermalinkFormatter.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\Field\FieldFormatter; +use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter; @@ -33,7 +34,15 @@ class CommentPermalinkFormatter extends StringFormatter { */ protected function getEntityUrl(EntityInterface $comment) { /** @var $comment \Drupal\comment\CommentInterface */ - return $comment->permalink(); + $body = ''; + if (!empty($comment->comment_body->value)) { + $body = $comment->comment_body->value; + } + $comment_permalink = $comment->permalink(); + $attributes = $comment_permalink->getOption('attributes') ?: array(); + $attributes += array('title' => Unicode::truncate($body, 128)); + $comment_permalink->setOption('attributes', $attributes); + return $comment_permalink; } /**