public function GeofieldItem::isEmpty in Geofield 8
Determines whether the data structure is empty.
Return value
bool TRUE if the data structure is empty, FALSE otherwise.
Overrides Map::isEmpty
File
- src/
Plugin/ Field/ FieldType/ GeofieldItem.php, line 192
Class
- GeofieldItem
- Plugin implementation of the 'geofield' field type.
Namespace
Drupal\geofield\Plugin\Field\FieldTypeCode
public function isEmpty() {
$value = $this
->get('value')
->getValue();
if (!empty($value)) {
/* @var \Drupal\geofield\GeoPHP\GeoPHPInterface $geo_php_wrapper */
// Note: Geofield FieldType doesn't support Dependency Injection yet
// (https://www.drupal.org/node/2053415).
$geo_php_wrapper = \Drupal::service('geofield.geophp');
/* @var \Geometry|null $geometry */
$geometry = $geo_php_wrapper
->load($value);
return $geometry instanceof \Geometry ? $geometry
->isEmpty() : FALSE;
}
return TRUE;
}