You are here

protected static function GeneralEntityReferenceFormatter::getEntityReferenceTokenPatterns in Formatter Suite 8

Returns an array of mappings from formatting styles to token strings.

Return value

string[] Returns an associative array with internal names as keys and token strings as values.

1 call to GeneralEntityReferenceFormatter::getEntityReferenceTokenPatterns()
GeneralEntityReferenceFormatter::viewElements in src/Plugin/Field/FieldFormatter/GeneralEntityReferenceFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/GeneralEntityReferenceFormatter.php, line 215

Class

GeneralEntityReferenceFormatter
Formats an entity reference as one or more links.

Namespace

Drupal\formatter_suite\Plugin\Field\FieldFormatter

Code

protected static function getEntityReferenceTokenPatterns() {
  $by = (string) t('by');
  $created = (string) t('Created');
  $updated = (string) t('Updated');

  // While generic patterns are listed here for the standard styles,
  // some of these are handled by custom code below so that they work
  // well for most entity types, even if the type doesn't support the
  // specific tokens used here.
  return [
    'id' => '[__PREFIX:id]',
    'title' => '[__PREFIX:title]',
    'title-id' => '[__PREFIX:title] ([__PREFIX:id])',
    'title-author' => '[__PREFIX:title] ' . $by . ' [__PREFIX:author:display-name]',
    'title-created' => '[__PREFIX:title] (' . $created . ' [__PREFIX:created])',
    'title-changed' => '[__PREFIX:title] (' . $updated . ' [__PREFIX:changed])',
  ];
}