function sarnia_field_get_property in Sarnia 7
Same name in this branch
- 7 sarnia.api.php \sarnia_field_get_property()
- 7 sarnia.module \sarnia_field_get_property()
Get the value of a Solr property from a 'sarnia' Solr document field.
Parameters
object $entity: A fully-loaded entity object.
array $field: A field info array.
string $property_name: The name of a Solr property to retrieve.
Return value
An array containing values from Solr. Even the properties of single-value Solr fields are returned as an array.
See also
sarnia_field_formatter_view().
2 calls to sarnia_field_get_property()
- SarniaViewsHandlerArgumentId::title in handlers/
handler_argument_id.inc - If the name solr property is not the id, load the sarnia entity and extract the name property.
- sarnia_field_formatter_view in ./
sarnia.field_formatter.inc - Implements hook_field_formatter_view().
File
- ./
sarnia.module, line 733
Code
function sarnia_field_get_property($entity, $field, $property_name) {
$value = array();
$field_name = $field['field_name'];
if (isset($entity->{$field_name}) && isset($entity->{$field_name}[$property_name])) {
// Return every property as if it is multi-valued, so that we don't have to
// put that logic in every formatter.
$value = $entity->{$field_name}[$property_name];
$value = is_array($value) ? $value : array(
$value,
);
}
return $value;
}