You are here

public function DataProviderBase::getPositionsFromViewsRow in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/DataProviderBase.php \Drupal\geolocation\DataProviderBase::getPositionsFromViewsRow()

Get positions from views row.

Parameters

\Drupal\views\ResultRow $row: Row.

\Drupal\views\Plugin\views\field\FieldPluginBase $views_field: Views field definition.

Return value

array Retrieved locations.

Overrides DataProviderInterface::getPositionsFromViewsRow

1 method overrides DataProviderBase::getPositionsFromViewsRow()
SearchAPI::getPositionsFromViewsRow in modules/geolocation_search_api/src/Plugin/geolocation/DataProvider/SearchAPI.php
Get positions from views row.

File

src/DataProviderBase.php, line 190

Class

DataProviderBase
Class DataProviderBase.

Namespace

Drupal\geolocation

Code

public function getPositionsFromViewsRow(ResultRow $row, FieldPluginBase $viewsField = NULL) {
  if (empty($viewsField)) {
    $viewsField = $this->viewsField;
  }
  $positions = [];
  $entity = $viewsField
    ->getEntity($row);
  if (isset($entity->{$viewsField->definition['field_name']})) {

    /** @var \Drupal\Core\Field\FieldItemListInterface $geo_items */
    $geo_items = $entity->{$viewsField->definition['field_name']};
    foreach ($geo_items as $item) {
      $positions[] = $this
        ->getPositionsFromItem($item);
    }
  }
  return $positions;
}