You are here

function comment_node_view_alter in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/comment/comment.module \comment_node_view_alter()
  2. 10 core/modules/comment/comment.module \comment_node_view_alter()

Implements hook_ENTITY_TYPE_view_alter() for node entities.

File

core/modules/comment/comment.module, line 226
Enables users to comment on published content.

Code

function comment_node_view_alter(array &$build, EntityInterface $node, EntityViewDisplayInterface $display) {
  if (\Drupal::moduleHandler()
    ->moduleExists('history')) {
    $build['#attributes']['data-history-node-id'] = $node
      ->id();
  }
}