FileFieldFormatter.php in Entity Embed 8
File
src/Plugin/entity_embed/EntityEmbedDisplay/FileFieldFormatter.php
View source
<?php
namespace Drupal\entity_embed\Plugin\entity_embed\EntityEmbedDisplay;
use Drupal\Core\Form\FormStateInterface;
class FileFieldFormatter extends EntityReferenceFieldFormatter {
public function getFieldValue() {
$value = parent::getFieldValue();
$value += array_intersect_key($this
->getConfiguration(), [
'description' => '',
]);
return $value;
}
public function defaultConfiguration() {
$defaults = parent::defaultConfiguration();
$defaults['description'] = '';
return $defaults;
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['description'] = [
'#type' => 'textfield',
'#title' => $this
->t('Description'),
'#default_value' => $this
->getConfigurationValue('description'),
'#description' => $this
->t('The description may be used as the label of the link to the file.'),
];
return $form;
}
}