You are here

function _pathauto_path_is_callback in Pathauto 7

Same name and namespace in other branches
  1. 5.2 pathauto.inc \_pathauto_path_is_callback()
  2. 5 pathauto.module \_pathauto_path_is_callback()
  3. 6.2 pathauto.inc \_pathauto_path_is_callback()
  4. 6 pathauto.inc \_pathauto_path_is_callback()

Verify if the given path is a valid menu callback.

Taken from menu_execute_active_handler().

Parameters

$path: A string containing a relative path.

Return value

TRUE if the path already exists.

1 call to _pathauto_path_is_callback()
pathauto_pathauto_is_alias_reserved in ./pathauto.module
Implements hook_pathauto_is_alias_reserved().

File

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

Code

function _pathauto_path_is_callback($path) {

  // We need to use a try/catch here because of a core bug which will throw an
  // exception if $path is something like 'node/foo/bar'.
  // @todo Remove when http://drupal.org/node/1003788 is fixed in core.
  try {
    $menu = menu_get_item($path);
  } catch (Exception $e) {
    return FALSE;
  }
  if (isset($menu['path']) && $menu['path'] == $path) {
    return TRUE;
  }
  elseif (is_file(DRUPAL_ROOT . '/' . $path) || is_dir(DRUPAL_ROOT . '/' . $path)) {

    // Do not allow existing files or directories to get assigned an automatic
    // alias. Note that we do not need to use is_link() to check for symbolic
    // links since this returns TRUE for either is_file() or is_dir() already.
    return TRUE;
  }
  return FALSE;
}