trait FileLinkFormatterTrait in File Link 8
Same name and namespace in other branches
- 2.0.x src/FileLinkFormatterTrait.php \Drupal\file_link\FileLinkFormatterTrait
Provide common methods for file link formatters.
Hierarchy
- trait \Drupal\file_link\FileLinkFormatterTrait
2 files declare their use of FileLinkFormatterTrait
- FileLinkFormatter.php in src/
Plugin/ Field/ FieldFormatter/ FileLinkFormatter.php - FileLinkSeparateFormatter.php in src/
Plugin/ Field/ FieldFormatter/ FileLinkSeparateFormatter.php
File
- src/
FileLinkFormatterTrait.php, line 10
Namespace
Drupal\file_linkView source
trait FileLinkFormatterTrait {
/**
* {@inheritdoc}
*/
public static function defaultSettings() {
return [
'format_size' => TRUE,
] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$elements['format_size'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Format size value'),
'#default_value' => $this
->getSetting('format_size'),
];
return $elements;
}
/**
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = parent::settingsSummary();
$summary[] = $this
->getSetting('format_size') ? $this
->t('Size value: formatted') : $this
->t('Size value: plain');
return $summary;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileLinkFormatterTrait:: |
public static | function | ||
FileLinkFormatterTrait:: |
public | function | ||
FileLinkFormatterTrait:: |
public | function |