You are here

function _ip_geoloc_plugin_style_get_base1 in IP Geolocation Views & Maps 8

Same name and namespace in other branches
  1. 7 views/ip_geoloc_plugin_style.inc \_ip_geoloc_plugin_style_get_base1()

Gets the location attribute machine name or views alias.

Parameters

string $row: Views result row.

string $location_field_name: Field location name.

string $location_field_alias: Views alias.

Return value

string Base name for location field.

1 call to _ip_geoloc_plugin_style_get_base1()
ip_geoloc_plugin_style_extract_locations in src/Plugin/views/style/ip_geoloc_plugin_style.inc
Extract an array of locations from the supplied views_plugin_style.

File

src/Plugin/views/style/ip_geoloc_plugin_style.inc, line 722
ip_geoloc_plugin_style.inc

Code

function _ip_geoloc_plugin_style_get_base1($row, $location_field_name, $location_field_alias) {
  $base = NULL;
  if (isset($location_field_alias)) {

    // The lines below are stripped back fast versions of this call:
    // $loc_field_value = $loc_field->get_value($row);
    $entity = $row->_field_data[$location_field_alias]['entity'];

    // The field value may not be there, i.e. no coordinates entered.
    if (isset($entity->{$location_field_name})) {
      $location_field_value = reset($entity->{$location_field_name});
      $base = is_array($location_field_value) ? reset($location_field_value) : $location_field_value;
    }
  }
  return $base;
}