public function SearchApiFieldTrait::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.
See also
\Drupal\views\Plugin\views\field\PrerenderList::getItems()
2 methods override SearchApiFieldTrait::getItems()
- SearchApiEntity::getItems in src/
Plugin/ views/ field/ SearchApiEntity.php - Gets an array of items for the field.
- SearchApiEntityField::getItems in src/
Plugin/ views/ field/ SearchApiEntityField.php - Gets an array of items for the field.
File
- src/
Plugin/ views/ field/ SearchApiFieldTrait.php, line 1192
Class
- SearchApiFieldTrait
- Provides a trait to use for Search API Views field handlers.
Namespace
Drupal\search_api\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
$property_path = $this
->getCombinedPropertyPath();
if (!empty($this->propertyReplacements[$property_path])) {
$property_path = $this->propertyReplacements[$property_path];
}
if (!empty($values->{$property_path})) {
// Although it's undocumented, the field handler base class assumes items
// will always be arrays. See #2648012 for documenting this.
$items = [];
foreach ((array) $values->{$property_path} as $i => $value) {
$item = [
'value' => $value,
];
if ($this->options['link_to_item']) {
$item['make_link'] = TRUE;
$item['url'] = $this
->getItemUrl($values, $i);
}
$items[] = $item;
}
return $items;
}
return [];
}