public function GeneralEmailFormatter::settingsSummary in Formatter Suite 8
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
- src/
Plugin/ Field/ FieldFormatter/ GeneralEmailFormatter.php, line 89
Class
- GeneralEmailFormatter
- Formats an email address.
Namespace
Drupal\formatter_suite\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$this
->sanitizeSettings();
$isMultiple = $this->fieldDefinition
->getFieldStorageDefinition()
->isMultiple();
$summary = [];
switch ($this
->getSetting('emailStyle')) {
default:
case 'plain':
$summary[] = $this
->t('Email address');
break;
case 'mailto':
$summary[] = $this
->t('Email address link');
break;
case 'custommailto':
$summary[] = $this
->t('Text with Email address link');
break;
}
// If the field can store multiple values, then summarize list style.
if ($isMultiple === TRUE) {
$listStyles = $this
->getListStyles();
$listStyle = $this
->getSetting('listStyle');
$listSeparator = $this
->getSetting('listSeparator');
$text = $listStyles[$listStyle];
if ($listStyle === 'span' && empty($listSeparator) === FALSE) {
$text .= $this
->t(', with separator');
}
$summary[] = $text;
}
return $summary;
}