You are here

function _pathauto_get_raw_tokens in Pathauto 6

Same name and namespace in other branches
  1. 6.2 pathauto.inc \_pathauto_get_raw_tokens()

Fetch an array of non-raw tokens that have matching raw tokens.

Return value

An array of tokens.

2 calls to _pathauto_get_raw_tokens()
PathautoUnitTestCase::testGetRawTokens in ./pathauto.test
Test _pathauto_get_raw_tokens().
_pathauto_validate_pattern_element in ./pathauto.admin.inc
Element validation callback for URL alias patterns.

File

./pathauto.inc, line 686
Miscellaneous functions for Pathauto.

Code

function _pathauto_get_raw_tokens() {
  static $raw_tokens;
  if (!isset($raw_tokens)) {
    $raw_tokens = array();

    // Build one big list of tokens.
    foreach (token_get_list('all') as $tokens) {
      $raw_tokens = array_merge($raw_tokens, array_keys($tokens));
    }

    // Filter out any tokens without -raw as a suffix.
    foreach ($raw_tokens as $index => $token) {
      if (substr($token, -4) !== '-raw') {
        unset($raw_tokens[$index]);
      }
    }
    array_unique($raw_tokens);
  }
  return $raw_tokens;
}