function IpGeoLocViewsPluginStyle::pluginStyleGetSearchApiValue in IP Geolocation Views & Maps 8
1 call to IpGeoLocViewsPluginStyle::pluginStyleGetSearchApiValue()
- IpGeoLocViewsPluginStyle::getViewResult in src/Services/IpGeoLocViewsPluginStyle.php
- Returns as an array the raw value(s) of a field in the results set.
File
- src/Services/IpGeoLocViewsPluginStyle.php, line 1268
Class
- IpGeoLocViewsPluginStyle
- Class IpGeoLocViewsPluginStyle.
Namespace
Drupal\ip_geoloc\Services
Code
function pluginStyleGetSearchApiValue($row, $field_name) {
$field_value = null;
if (isset($row->_entity_properties[$field_name])) {
$field_value = $row->_entity_properties[$field_name];
}
elseif ($last_ = strrpos($field_name, '_')) {
$alt_field_name = Unicode::substr($field_name, $last_ + 1);
if (isset($row->_entity_properties[$alt_field_name])) {
$field_value = $row->_entity_properties[$alt_field_name];
}
}
else {
$alt_field_name = 'field_' . $field_name;
if (isset($row->_entity_properties[$alt_field_name])) {
$field_value = $row->_entity_properties[$alt_field_name];
}
}
if (isset($field_value)) {
}
else {
$this
->messenger($this->stringTranslation
->translate('IPGV&M: Could not retrieve value of field %name, as its name does not appear among these Search API keys: %keys', array(
'%name' => $field_name,
'%keys' => implode(', ', array_keys($row->_entity_properties)),
)), 'warning', FALSE);
}
return isset($field_value) ? $field_value : '';
}