public function SearchApiAlterAddHierarchy::propertyInfo in Search API 7
Implements SearchApiAlterCallbackInterface::propertyInfo().
Overrides SearchApiAbstractAlterCallback::propertyInfo
File
- includes/
callback_add_hierarchy.inc, line 119 - Contains SearchApiAlterAddHierarchy.
Class
- SearchApiAlterAddHierarchy
- Adds all ancestors for hierarchical fields.
Code
public function propertyInfo() {
if (empty($this->options['fields'])) {
return array();
}
$ret = array();
$wrapper = $this->index
->entityWrapper(NULL, FALSE);
foreach ($this->options['fields'] as $field) {
list($key, $prop) = explode(':', $field);
if (!isset($wrapper->{$key})) {
continue;
}
$child = $wrapper->{$key};
while (search_api_is_list_type($child
->type())) {
$child = $child[0];
}
if (!isset($child->{$prop})) {
continue;
}
if (!isset($ret[$key])) {
$ret[$key] = $child
->info();
$type = search_api_extract_inner_type($ret[$key]['type']);
$ret[$key]['type'] = "list<{$type}>";
$ret[$key]['getter callback'] = 'entity_property_verbatim_get';
// The return value of info() has some additional internal values set,
// which we have to unset for the use here.
unset($ret[$key]['name'], $ret[$key]['parent'], $ret[$key]['langcode'], $ret[$key]['clear'], $ret[$key]['property info alter'], $ret[$key]['property defaults']);
}
if (isset($ret[$key]['bundle'])) {
$info = $child->{$prop}
->info();
if (empty($info['bundle']) || $ret[$key]['bundle'] != $info['bundle']) {
unset($ret[$key]['bundle']);
}
}
}
return $ret;
}