protected function FileDownloadLink::getExampleToken in File Download Link 8
A helper function for the config form.
Return value
string An example link text with tokens.
2 calls to FileDownloadLink::getExampleToken()
- FileDownloadLink::getTokenExampleMarkup in src/
Plugin/ Field/ FieldFormatter/ FileDownloadLink.php - A helper function for the config form.
- FileDownloadLink::getTokenWarningMarkup in src/
Plugin/ Field/ FieldFormatter/ FileDownloadLink.php - A helper function for the config form.
File
- src/
Plugin/ Field/ FieldFormatter/ FileDownloadLink.php, line 352
Class
- FileDownloadLink
- Plugin implementation of the 'file_download_link' formatter.
Namespace
Drupal\file_download_link\Plugin\Field\FieldFormatterCode
protected function getExampleToken() {
$entity_type = $this->fieldDefinition
->getTargetEntityTypeId();
$field = $this->fieldDefinition
->getName();
$type = $this->fieldDefinition
->getType();
// If token is on, let's be extra sure about our token name.
if ($this->moduleHandler
->moduleExists('token')) {
$entity_type = $this->tokenEntityMapper
->getTokenTypeForEntityType($entity_type);
}
if ($type == 'file') {
return "[{$entity_type}:{$field}:description] ([file:size])";
}
else {
return "[{$entity_type}:{$field}:alt] ([file:size])";
}
}