public function AggregatedFieldProperty::getFieldDescription in Search API 8
Retrieves the description for a field based on this property.
Parameters
\Drupal\search_api\Item\FieldInterface $field: The field.
Return value
string|null A human-readable description for the field, or NULL if the field has no description.
Overrides ConfigurablePropertyBase::getFieldDescription
File
- src/
Plugin/ search_api/ processor/ Property/ AggregatedFieldProperty.php, line 125
Class
- AggregatedFieldProperty
- Defines an "aggregated field" property.
Namespace
Drupal\search_api\Plugin\search_api\processor\PropertyCode
public function getFieldDescription(FieldInterface $field) {
$index = $field
->getIndex();
$available_properties = $this
->getAvailableProperties($index);
$datasource_label_prefixes = $this
->getDatasourceLabelPrefixes($index);
$configuration = $field
->getConfiguration();
$fields = [];
foreach ($configuration['fields'] as $combined_id) {
list($datasource_id, $property_path) = Utility::splitCombinedId($combined_id);
$label = $property_path;
if (isset($available_properties[$combined_id])) {
$label = $available_properties[$combined_id]
->getLabel();
}
$fields[] = $datasource_label_prefixes[$datasource_id] . $label;
}
$type = $this
->getTypes()[$configuration['type']];
$arguments = [
'@type' => $type,
'@fields' => implode(', ', $fields),
];
return $this
->t('A @type aggregation of the following fields: @fields.', $arguments);
}