public function ProductAttributesOverview::settingsSummary in Commerce Core 8.2
Returns a short summary for the current formatter settings.
If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.
Return value
string[] A short summary of the formatter settings.
Overrides FormatterBase::settingsSummary
File
- modules/
product/ src/ Plugin/ Field/ FieldFormatter/ ProductAttributesOverview.php, line 164
Class
- ProductAttributesOverview
- Plugin implementation of the 'commerce_product_attributes_overview' formatter.
Namespace
Drupal\commerce_product\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$attribute_storage = $this->entityTypeManager
->getStorage('commerce_product_attribute');
$attributes = [];
if (empty($this
->getSetting('attributes'))) {
$attributes[] = $this
->t('None');
}
else {
$attributes = $attribute_storage
->loadMultiple(array_filter($this
->getSetting('attributes')));
$attributes = EntityHelper::extractLabels($attributes);
}
$summary[] = $this
->t('Displaying the following attributes: @attributes', [
'@attributes' => implode(', ', $attributes),
]);
$summary[] = $this
->t('Attribute value display mode: @mode', [
'@mode' => $this
->getSetting('view_mode'),
]);
return $summary;
}