You are here

public static function VotingApiReactionItem::generateSampleValue in Voting API Reaction 8

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

src/Plugin/Field/FieldType/VotingApiReactionItem.php, line 161

Class

VotingApiReactionItem
Plugin implementation of the 'votingapi_reaction' field type.

Namespace

Drupal\votingapi_reaction\Plugin\Field\FieldType

Code

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