You are here

function access_unpublished_token_info in Access unpublished 8

Implements hook_token_info().

File

./access_unpublished.tokens.inc, line 15
Contains access_unpublished token includes.

Code

function access_unpublished_token_info() {
  $tokens = [];
  foreach (\Drupal::entityTypeManager()
    ->getDefinitions() as $entity_type_id => $entity_type) {
    if (AccessUnpublished::applicableEntityType($entity_type)) {

      // @todo Remove after https://drupal.org/i/2163027 has landed, also @see comment_token_info().
      $token_type = $entity_type_id == 'taxonomy_term' ? 'term' : $entity_type_id;
      $tokens[$token_type] = [
        'access-unpublished-url' => [
          'name' => t('Access Unpublished URL'),
          'description' => t('The URL containing the hash. The most recently changed unexpired access token is used.'),
        ],
      ];
    }
  }
  return [
    'tokens' => $tokens,
  ];
}