if (!
empty($links)) { $entity_links['comment__' .
$field_name] =
[ '#theme' => 'links__entity__comment__' .
$field_name,
'#links' =>
$links,
'#attributes' =>
['class' =>
['links', 'inline'
]],
];
if ($view_mode == 'teaser' &&
$this->moduleHandler->
moduleExists('history'
) &&
$this->currentUser->
isAuthenticated()) { $entity_links['comment__' .
$field_name]['#cache'
]['contexts'
][] = 'user';
$entity_links['comment__' .
$field_name]['#attached'
]['library'
][] = 'comment/drupal.node-new-comments-link';
// Embed the metadata for the "X new comments" link (if any) on this
// entity.
$entity_links['comment__' .
$field_name]['#attached'
]['drupalSettings'
]['history'
]['lastReadTimestamps'
][$entity->
id()] =
(int) history_read($entity->
id());
$new_comments =
$this->commentManager->
getCountNewComments($entity);
if ($new_comments > 0
) { $page_number =
$this->entityTypeManager
->
getStorage('comment'
) ->
getNewCommentPageNumber($entity->
{$field_name}->comment_count,
$new_comments,
$entity,
$field_name);
$query =
$page_number ?
['page' =>
$page_number] : NULL;
$value =
[ 'new_comment_count' =>
(int) $new_comments,
'first_new_comment_link' =>
$entity->
toUrl('canonical',
[ 'query' =>
$query,
'fragment' => 'new',
])