You are here

function _pathauto_existing_alias_data in Pathauto 7

Same name and namespace in other branches
  1. 5.2 pathauto.inc \_pathauto_existing_alias_data()
  2. 6.2 pathauto.inc \_pathauto_existing_alias_data()
  3. 6 pathauto.inc \_pathauto_existing_alias_data()

Fetches an existing URL alias given a path and optional language.

Parameters

string $source: An internal Drupal path.

string $language: An optional language code to look up the path in.

Return value

bool|array FALSE if no alias was found or an associative array containing the following keys:

  • pid: Unique path alias identifier.
  • alias: The URL alias.
1 call to _pathauto_existing_alias_data()
pathauto_create_alias in ./pathauto.inc
Apply patterns to create an alias.

File

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

Code

function _pathauto_existing_alias_data($source, $language = LANGUAGE_NONE) {
  $pid = db_query_range("SELECT pid FROM {url_alias} WHERE source = :source AND language IN (:language, :language_none) ORDER BY language DESC, pid DESC", 0, 1, array(
    ':source' => $source,
    ':language' => $language,
    ':language_none' => LANGUAGE_NONE,
  ))
    ->fetchField();
  return path_load(array(
    'pid' => $pid,
  ));
}