You are here

function message_example_comment_insert in Message 8

Same name and namespace in other branches
  1. 7 message_example/message_example.module \message_example_comment_insert()

Implements hook_comment_insert().

File

modules/message_example/message_example.module, line 27
Holds hook implementation for the Message example module.

Code

function message_example_comment_insert(Comment $comment) {
  $message = Message::create([
    'template' => 'example_create_comment',
    'uid' => $comment
      ->getOwnerId(),
  ]);
  $message
    ->set('field_comment_reference', $comment);
  $message
    ->set('field_published', $comment
    ->isPublished());
  $message
    ->save();
}