public function SearchApiEntityField::getItems in Search API 8
Gets an array of items for the field.
Items should be associative arrays with, if possible, "value" as the actual displayable value of the item, plus any items that might be found in the "alter" options array for creating links, etc., such as "path", "fragment", "query", etc. Additionally, items that might be turned into tokens should also be in this array.
Parameters
\Drupal\views\ResultRow $values: The result row object containing the values.
Return value
array[] An array of items for the field, with each item being an array itself.
Overrides SearchApiFieldTrait::getItems
See also
\Drupal\views\Plugin\views\field\PrerenderList::getItems()
File
- src/
Plugin/ views/ field/ SearchApiEntityField.php, line 292
Class
- SearchApiEntityField
- Displays entity field data.
Namespace
Drupal\search_api\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
if (!$this->options['field_rendering']) {
if ($this->fallbackHandler instanceof MultiItemsFieldHandlerInterface) {
return $this->fallbackHandler
->getItems($values);
}
return [];
}
if ($values->search_api_datasource != $this
->getDatasourceId()) {
return [];
}
$parent_path = $this
->getParentPath();
$combined_parent_path = $this
->createCombinedPropertyPath($this
->getDatasourceId(), $parent_path);
if (empty($values->_relationship_objects[$combined_parent_path])) {
return [];
}
$build = [];
foreach (array_keys($values->_relationship_objects[$combined_parent_path]) as $i) {
$this->valueIndex = $i;
$build[] = parent::getItems($values);
}
return $build ? call_user_func_array('array_merge', $build) : [];
}