You are here

function filehash_token_info in File Hash 8

Same name and namespace in other branches
  1. 7 filehash.tokens.inc \filehash_token_info()

Implements hook_token_info().

File

./filehash.tokens.inc, line 13
Tokens for file hash module.

Code

function filehash_token_info() {
  $info = [];
  $names = filehash_names();
  foreach (filehash_algos() as $algo) {
    $info['tokens']['file']["filehash-{$algo}"] = [
      'name' => t('@algo hash', [
        '@algo' => $names[$algo],
      ]),
      'description' => t('The @algo hash of the file.', [
        '@algo' => $names[$algo],
      ]),
    ];
    $info['tokens']['file']["filehash-{$algo}-pair-1"] = [
      'name' => t('@algo hash: Initial pair', [
        '@algo' => $names[$algo],
      ]),
      'description' => t('The @algo hash of the file: first and second characters.', [
        '@algo' => $names[$algo],
      ]),
    ];
    $info['tokens']['file']["filehash-{$algo}-pair-2"] = [
      'name' => t('@algo hash: Second pair', [
        '@algo' => $names[$algo],
      ]),
      'description' => t('The @algo hash of the file: third and fourth characters.', [
        '@algo' => $names[$algo],
      ]),
    ];
  }
  return $info;
}