You are here

public static function CommentItem::generateSampleValue in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php \Drupal\comment\Plugin\Field\FieldType\CommentItem::generateSampleValue()
  2. 10 core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php \Drupal\comment\Plugin\Field\FieldType\CommentItem::generateSampleValue()

Generates placeholder field values.

Useful when populating site with placeholder content during site building or profiling.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.

Return value

array An associative array of values.

Overrides FieldItemBase::generateSampleValue

File

core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php, line 201

Class

CommentItem
Plugin implementation of the 'comment' field type.

Namespace

Drupal\comment\Plugin\Field\FieldType

Code

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
  $statuses = [
    CommentItemInterface::HIDDEN,
    CommentItemInterface::CLOSED,
    CommentItemInterface::OPEN,
  ];
  return [
    'status' => $statuses[mt_rand(0, count($statuses) - 1)],
  ];
}