public function Grouping::getSupportedFields in Search API Grouping 8
Returns an array of supported fields to choose of.
This function respects the server behind the index to provide only valid fields.
Return value
array An associative array with child arrays for the supported fields for each feature: [ 'field_options' => [], 'field_sorts' => [], 'field' => [], ];
1 call to Grouping::getSupportedFields()
- Grouping::buildConfigurationForm in src/
Plugin/ search_api/ processor/ Grouping.php - Return the settings form for this processor.
File
- src/
Plugin/ search_api/ processor/ Grouping.php, line 118
Class
- Grouping
- Processor for grouping up items on behalf of user defined fields.
Namespace
Drupal\search_api_grouping\Plugin\search_api\processorCode
public function getSupportedFields() {
$fields = $this->index
->getFields();
$supported_fields = [
'field_options' => [],
'field_sorts' => [
'' => $this
->t('None'),
'search_api_relevance' => $this
->t('Score/Relevance'),
],
'default_fields' => [],
];
foreach ($fields as $name => $field) {
if ($field
->getType() == 'string' || $field
->getType() == 'integer') {
$conversion_msg = $field
->getType() != 'string' ? ' (' . $this
->t('Converted to string for indexing') . ')' : NULL;
$supported_fields['field_options'][$name] = $field
->getLabel() . $conversion_msg;
if (!empty($default_fields[$name]) || !isset($this->configuration['grouping_fields']) && $this
->testField($name, $field)) {
$supported_fields['default_fields'][$name] = $name;
}
$supported_fields['field_sorts'][$name] = $field
->getLabel();
}
}
return $supported_fields;
}