You are here

public function KmlNormalizer::supportsNormalization in farmOS 2.x

File

modules/core/kml/src/Normalizer/KmlNormalizer.php, line 86

Class

KmlNormalizer
Normalizes GeometryWrapper objects into array for the Kml encoder.

Namespace

Drupal\farm_kml\Normalizer

Code

public function supportsNormalization($data, $format = NULL) {

  // First check if the format is supported.
  if ($format !== static::FORMAT) {
    return FALSE;
  }

  // Change data to an array.
  if (!is_array($data)) {
    $data = [
      $data,
    ];
  }

  // Ensure all items are GeometryWrappers.
  $invalid_count = count(array_filter($data, function ($object) {
    return !$object instanceof GeometryWrapper;
  }));
  return $invalid_count === 0;
}