You are here

private function GeofieldWidget::getGeoPhpType in farmOS 2.x

Helper function to check if the file extension is a supported geometry.

Parameters

\Drupal\file\FileInterface $file: The file to check.

Return value

string|false The GeoPHP type or FALSE.

1 call to GeofieldWidget::getGeoPhpType()
GeofieldWidget::fileParse in modules/core/map/src/Plugin/Field/FieldWidget/GeofieldWidget.php
Submit function to parse geometries from uploaded files.

File

modules/core/map/src/Plugin/Field/FieldWidget/GeofieldWidget.php, line 321

Class

GeofieldWidget
Plugin implementation of the map 'geofield' widget.

Namespace

Drupal\farm_map\Plugin\Field\FieldWidget

Code

private function getGeoPhpType(FileInterface $file) {

  // Get the file extension.
  $matches = [];
  if (preg_match('/(?<=\\.)[^.]+$/', $file
    ->getFilename(), $matches) && isset($matches[0])) {

    // Return the associated GeoPHP type.
    if (isset(self::$geoPhpTypes[$matches[0]])) {
      return self::$geoPhpTypes[$matches[0]];
    }
  }

  // Otherwise the file extension is not a valid GeoPHP geometry type.
  return FALSE;
}