protected function SearchApiDenormalizedEntityField::createDocument in Search API Grouping 7.2
Create a denormalized item for indexing.
Parameters
array $item: The item to index.
string $item_id: The item id of the item to index.
Return value
array Denormalized item to index.
1 call to SearchApiDenormalizedEntityField::createDocument()
- SearchApiDenormalizedEntityField::preprocessIndexItems in includes/
processor_denormalize_field.inc - Denormalizes items on behalf of multivalue fields.
File
- includes/
processor_denormalize_field.inc, line 145 - Processor for configuring the denormalization per index.
Class
- SearchApiDenormalizedEntityField
- Processor to configure and handle the denormalization per index.
Code
protected function createDocument($item, $item_id) {
$fields = $this
->getDenormalizationFields();
$parts = explode(SEARCH_API_GROUPING_ENTITY_FIELD_SEPERATOR, $item_id);
// Unshift non delta values to ensure the $fields_index matches.
$entity_type = array_shift($parts);
$entity_id = array_shift($parts);
$fields_index = array_flip(array_keys($fields));
foreach ($item as $index => $data) {
list($key) = explode(':', $index, 2);
if (isset($fields[$key]) && !empty($data['value'])) {
$item[$index]['value'] = array_intersect_key($data['value'], array(
$parts[$fields_index[$key]] => $parts[$fields_index[$key]],
));
}
}
return $item;
}