You are here

public static function GeolocationItem::generateSampleValue in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/Field/FieldType/GeolocationItem.php \Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem::generateSampleValue()
  2. 8 src/Plugin/Field/FieldType/GeolocationItem.php \Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem::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

src/Plugin/Field/FieldType/GeolocationItem.php, line 113

Class

GeolocationItem
Plugin implementation of the 'geolocation' field type.

Namespace

Drupal\geolocation\Plugin\Field\FieldType

Code

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
  $values['lat'] = rand(-89, 90) - rand(0, 999999) / 1000000;
  $values['lng'] = rand(-179, 180) - rand(0, 999999) / 1000000;
  return $values;
}