You are here

function media_entity_token_info in Media entity 8

Implements hook_token_info().

File

./media_entity.tokens.inc, line 17
Builds placeholder replacement tokens for media_entity-related data.

Code

function media_entity_token_info() {
  $type = [
    'name' => t('Media'),
    'description' => t('Tokens related to individual media items.'),
    'needs-data' => 'media',
  ];

  // Core tokens for media.
  $media['mid'] = [
    'name' => t("Media ID"),
    'description' => t('The unique ID of the media item.'),
  ];
  $media['uuid'] = [
    'name' => t("Media UUID"),
    'description' => t('The unique UUID of the media item.'),
  ];
  $media['vid'] = [
    'name' => t("Revision ID"),
    'description' => t("The unique ID of the media's latest revision."),
  ];
  $media['bundle'] = [
    'name' => t("Media bundle"),
  ];
  $media['bundle-name'] = [
    'name' => t("Media bundle name"),
    'description' => t("The human-readable name of the media bundle."),
  ];
  $media['langcode'] = [
    'name' => t('Language code'),
    'description' => t('The language code of the language the media is written in.'),
  ];
  $media['name'] = [
    'name' => t('Name'),
    'description' => t('The name of this media.'),
  ];
  $media['type'] = [
    'name' => t("Type"),
    'description' => t("The type of this media."),
  ];
  $node['author'] = [
    'name' => t("Author"),
    'type' => 'user',
  ];
  $media['url'] = [
    'name' => t("URL"),
    'description' => t("The URL of the media."),
  ];
  $media['edit-url'] = [
    'name' => t("Edit URL"),
    'description' => t("The URL of the media's edit page."),
  ];

  // Chained tokens for media.
  $media['created'] = [
    'name' => t("Date created"),
    'type' => 'date',
  ];
  $media['changed'] = [
    'name' => t("Date changed"),
    'description' => t("The date the media was most recently updated."),
    'type' => 'date',
  ];
  return [
    'types' => [
      'media' => $type,
    ],
    'tokens' => [
      'media' => $media,
    ],
  ];
}