public function SarniaViewsHandlerArgumentId::title in Sarnia 7
If the name solr property is not the id, load the sarnia entity and extract the name property.
Overrides SarniaViewsHandlerArgument::title
File
- handlers/
handler_argument_id.inc, line 61 - Views argument handler for Solr document Ids.
Class
- SarniaViewsHandlerArgumentId
- @file Views argument handler for Solr document Ids.
Code
public function title() {
if (!empty($this->argument) && $this->options['name_solr_property'] != $this->definition['solr_property']) {
// The query has not run yet, so we need to load the entity in order to
// get a property from it.
$entity_info = sarnia_entity_type_load_by_index($this->definition['search_api_index']);
$entities = entity_load($entity_info['machine_name'], array(
$this->argument,
));
// Extract the solr property value from the entity.
if (!empty($entities[$this->argument])) {
$values = sarnia_field_get_property($entities[$this->argument], array(
'field_name' => $this->name_field,
), $this->options['name_solr_property']);
if (!empty($values)) {
return check_plain(current($values));
}
}
}
// Default to returning just the argument.
return check_plain($this->argument);
}