public function PdfDefault::settingsSummary in PDF 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/ PdfDefault.php, line 129
Class
- PdfDefault
- Plugin annotation @FieldFormatter( id = "pdf_default", label = @Translation("PDF: Default viewer of PDF.js"), description = @Translation("Use the default viewer like http://mozilla.github.io/pdf.js/web/viewer.html."), field_types = {"file"} )
Namespace
Drupal\pdf\Plugin\Field\FieldFormatterCode
public function settingsSummary() {
$summary = [];
$keep_pdfjs = $this
->getSetting('keep_pdfjs');
$width = $this
->getSetting('width');
$height = $this
->getSetting('height');
if (empty($keep_pdfjs) && empty($width) && empty($height)) {
$summary[] = $this
->t('No settings');
}
else {
$summary[] = t('Use pdf.js even when users have PDF reader plugin: @keep_pdfjs', [
'@keep_pdfjs' => $keep_pdfjs ? t('Yes') : t('No'),
]) . '. ' . t('Width: @width , Height: @height', [
'@width' => $width,
'@height' => $height,
]);
}
return $summary;
}