You are here

function _monitoring_setup_create_comment in Monitoring 8

Same name and namespace in other branches
  1. 7 monitoring.setup.inc \_monitoring_setup_create_comment()

Creates comments for testing purposes.

Parameters

array $settings: Comment data.

Return value

object Crated comment.

1 call to _monitoring_setup_create_comment()
monitoring_demo_install in modules/demo/monitoring_demo.install
Implements hook_install().

File

modules/demo/monitoring_demo.install, line 148
Install file of the monitoring_demo module.

Code

function _monitoring_setup_create_comment($settings = array()) {
  $random = new Random();
  $settings += array(
    'subject' => $random
      ->name(),
    'entity_id' => $settings['entity_id'],
    'field_name' => 'comment',
    'entity_type' => 'node',
    'comment_type' => 'comment',
    'comment_body' => $random
      ->name(40),
  );
  $comment = Comment::create($settings);
  $comment
    ->save();
  return $comment;
}