You are here

public static function OfficeHoursItem::generateSampleValue in Office Hours 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/OfficeHoursItem.php, line 223

Class

OfficeHoursItem
Plugin implementation of the 'office_hours' field type.

Namespace

Drupal\office_hours\Plugin\Field\FieldType

Code

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
  $values['day'] = mt_rand(0, 6);
  $values['starthours'] = mt_rand(00, 23) * 100;
  $values['endhours'] = mt_rand(00, 23) * 100;
  $values['comment'] = mt_rand(0, 1) ? 'additional text' : '';
  return $values;
}