You are here

protected function GeofieldBaseWidget::geofieldBackendValue in Geofield 8

Return the specific Geofield Backend Value.

Falls back into WKT format, in case Geofield Backend undefined.

Parameters

mixed|null $value: The data to load.

Return value

mixed|null The specific backend format value.

3 calls to GeofieldBaseWidget::geofieldBackendValue()
GeofieldDefaultWidget::massageFormValues in src/Plugin/Field/FieldWidget/GeofieldDefaultWidget.php
Massages the form values into the format expected for field values.
GeofieldDmsWidget::massageFormValues in src/Plugin/Field/FieldWidget/GeofieldDmsWidget.php
Massages the form values into the format expected for field values.
GeofieldLatLonWidget::massageFormValues in src/Plugin/Field/FieldWidget/GeofieldLatLonWidget.php
Massages the form values into the format expected for field values.

File

src/Plugin/Field/FieldWidget/GeofieldBaseWidget.php, line 111

Class

GeofieldBaseWidget
Abstract class for Geofield widgets.

Namespace

Drupal\geofield\Plugin\Field\FieldWidget

Code

protected function geofieldBackendValue($value) {
  $output = NULL;

  /* @var \Geometry|null $geom */
  if ($this->geofieldBackend && ($geom = $this->geoPhpWrapper
    ->load($value))) {
    $output = $this->geofieldBackend
      ->save($geom);
  }
  elseif ($geom = $this->geoPhpWrapper
    ->load($value)) {
    $output = $geom
      ->out('wkt');
  }
  return $output;
}