public static function GeolocationGeometryBase::propertyDefinitions in Geolocation Field 8.3
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
- modules/
geolocation_geometry/ src/ Plugin/ Field/ FieldType/ GeolocationGeometryBase.php, line 58
Class
- GeolocationGeometryBase
- Class Geolocation Geometry Base.
Namespace
Drupal\geolocation_geometry\Plugin\Field\FieldTypeCode
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$geom_type = explode("_", $field_definition
->getType())[2];
$properties['geometry'] = DataDefinition::create('string')
->setComputed('true')
->setLabel(t('Geometry'));
$properties['wkt'] = DataDefinition::create('string')
->setLabel(t('WKT'))
->addConstraint('GeometryType', [
'geometryType' => $geom_type,
'type' => 'WKT',
]);
$properties['geojson'] = DataDefinition::create('string')
->setLabel(t('GeoJSON'))
->addConstraint('GeometryType', [
'geometryType' => $geom_type,
'type' => 'GeoJSON',
]);
$properties['data'] = MapDataDefinition::create()
->setLabel(t('Meta data'));
return $properties;
}