You are here

public static function GeolocationItem::propertyDefinitions 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::propertyDefinitions()
  2. 8 src/Plugin/Field/FieldType/GeolocationItem.php \Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem::propertyDefinitions()

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FieldItemInterface::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

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

Class

GeolocationItem
Plugin implementation of the 'geolocation' field type.

Namespace

Drupal\geolocation\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties['lat'] = DataDefinition::create('float')
    ->setLabel(t('Latitude'));
  $properties['lng'] = DataDefinition::create('float')
    ->setLabel(t('Longitude'));
  $properties['lat_sin'] = DataDefinition::create('float')
    ->setLabel(t('Latitude sine'))
    ->setComputed(TRUE);
  $properties['lat_cos'] = DataDefinition::create('float')
    ->setLabel(t('Latitude cosine'))
    ->setComputed(TRUE);
  $properties['lng_rad'] = DataDefinition::create('float')
    ->setLabel(t('Longitude radian'))
    ->setComputed(TRUE);
  $properties['data'] = MapDataDefinition::create()
    ->setLabel(t('Meta data'));
  $properties['value'] = DataDefinition::create('string')
    ->setLabel(t('Computed lat,lng value'))
    ->setComputed(TRUE)
    ->setInternal(FALSE)
    ->setClass(GeolocationComputed::class);
  return $properties;
}