function hook_comment_create

Act on a newly created comment.

This hook runs after a new comment object has just been instantiated. It can be used to set initial values, e.g. to provide defaults.

Parameters

\Drupal\comment\Plugin\Core\Entity\Comment $comment: The comment object.

Related topics

1 function implements hook_comment_create()

File

drupal/core/modules/comment/comment.api.php, line 60
Hooks provided by the Comment module.

Code

function hook_comment_create(\Drupal\comment\Plugin\Core\Entity\Comment $comment) {
  if (!isset($comment->foo)) {
    $comment->foo = 'some_initial_value';
  }
}