trait ContentModerationNotificationCreateTrait in Content Moderation Notifications 8.3
Helper trait for creating notification entities.
Hierarchy
- trait \Drupal\Tests\content_moderation_notifications\Kernel\ContentModerationNotificationCreateTrait
File
- tests/
src/ Kernel/ ContentModerationNotificationCreateTrait.php, line 10
Namespace
Drupal\Tests\content_moderation_notifications\KernelView source
trait ContentModerationNotificationCreateTrait {
/**
* Creates a content moderation notification entity with defaults.
*
* @param array $values
* An array of values. Defaults are provided for any items not passed in.
*
* @return \Drupal\content_moderation_notifications\ContentModerationNotificationInterface
* The saved entity.
*/
protected function createNotification(array $values = []) {
$values += [
'id' => mb_strtolower($this
->randomMachineName()),
'workflow' => 'editorial',
'subject' => $this
->randomString(),
'status' => 1,
'body' => [
'value' => $this->randomGenerator
->paragraphs(2),
'format' => 'filtered_html',
],
'roles' => [],
'emails' => '',
'transitions' => [],
];
$notification = ContentModerationNotification::create($values);
$notification
->save();
return $notification;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentModerationNotificationCreateTrait:: |
protected | function | Creates a content moderation notification entity with defaults. |