Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Token descriptions in hook_token_info() are now optional.

Drupal 7


/**
 * Implements hook_token_info().
 */
function foo_token_info() {
    $token['foo']['bar'] = array(
      'name' => t('Bar'),
      'description' => t('The bar of a foo.'),
    );
  }

  return array(
    'tokens' => $token,
  );
}

Drupal 8


/**
 * Implements hook_token_info().
 */
function foo_token_info() {
  $token['foo']['bar'] = array(
    'name' => t('Bar'),
  );

  return array(
    'tokens' => $token,
  );
}
Impacts: 
Module developers

Comments

baisong’s picture

Should the D8 snippet be like this?

/**
 * Implements hook_token_info().
 */
function foo_token_info() {
  $token['foo']['bar'] = array(
    'name' => t('Bar'),
  );
  return array(
    'tokens' => $token,
  );
}

(Note: one fewer end-curly-bracket)

xano’s picture

Yes. I just corrected the snippet. Thank you for letting us know!