You are here

protected function FileDownloadLink::getTokenExampleMarkup in File Download Link 8

A helper function for the config form.

Return value

string An example of how to leverage token.

1 call to FileDownloadLink::getTokenExampleMarkup()
FileDownloadLink::settingsForm in src/Plugin/Field/FieldFormatter/FileDownloadLink.php
Returns a form to configure settings for the formatter.

File

src/Plugin/Field/FieldFormatter/FileDownloadLink.php, line 390

Class

FileDownloadLink
Plugin implementation of the 'file_download_link' formatter.

Namespace

Drupal\file_download_link\Plugin\Field\FieldFormatter

Code

protected function getTokenExampleMarkup() {
  $type = $this->fieldDefinition
    ->getType();
  $delta_help = '';
  if ($this->fieldDefinition
    ->getFieldStorageDefinition()
    ->getCardinality() != 1) {
    $field = $this->fieldDefinition
      ->getName();
    $delta_help = $this
      ->t('<p>Note that you do not need to indicate a delta value for the @field token. The appropriate delta is used automatically.</p>', [
      '@field' => $field,
    ]);
  }
  if ($type == 'file') {
    return $this
      ->t('<p>You can show the file description followed by the file size like this:<code>@example</code></p>@delta_help', [
      '@example' => $this
        ->getExampleToken(),
      '@delta_help' => $delta_help,
    ]);
  }
  else {
    return $this
      ->t('<p>You can show the alt text followed by the file size like this:<code>@example</code></p>@delta_help', [
      '@example' => $this
        ->getExampleToken(),
      '@delta_help' => $delta_help,
    ]);
  }
}