Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 8 |
| DefaultFileFormatter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 8 |
| defaultSettings | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| settingsForm | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| viewValue | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\file\Plugin\Field\FieldFormatter\DefaultFileFormatter. | |
| */ | |
| namespace Drupal\file\Plugin\Field\FieldFormatter; | |
| use Drupal\Core\Field\FieldItemInterface; | |
| use Drupal\Core\Form\FormStateInterface; | |
| /** | |
| * Formatter for a text field on a file entity that links the field to the file. | |
| * | |
| * @FieldFormatter( | |
| * id = "file_link", | |
| * label = @Translation("File link"), | |
| * field_types = { | |
| * "string" | |
| * } | |
| * ) | |
| */ | |
| class DefaultFileFormatter extends BaseFieldFileFormatterBase { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public static function defaultSettings() { | |
| $settings = parent::defaultSettings(); | |
| $settings['link_to_file'] = TRUE; | |
| return $settings; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function settingsForm(array $form, FormStateInterface $form_state) { | |
| // We don't call the parent in order to bypass the link to file form. | |
| return $form; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function viewValue(FieldItemInterface $item) { | |
| return $item->value; | |
| } | |
| } |