Given an alias, return its Drupal system URL if one exists. Otherwise, return FALSE.
$path: The path to investigate for corresponding system URLs.
$langcode: Optional language code to search the path with. Defaults to the page language. If there's no path defined for that language it will search paths without language.
A Drupal system path, or FALSE if no path was found.
protected function lookupPathSource($path, $langcode) {
if ($this->whitelist && !isset($this->noSource[$langcode][$path])) {
// Look for the value $path within the cached $map
$source = FALSE;
if (!isset($this->lookupMap[$langcode]) || !($source = array_search($path, $this->lookupMap[$langcode]))) {
$args = array(
':alias' => $path,
':langcode' => $langcode,
':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
);
// See the queries above.
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
unset($args[':langcode']);
$result = $this->connection
->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :langcode_undetermined ORDER BY pid DESC", $args);
}
elseif ($langcode > LANGUAGE_NOT_SPECIFIED) {
$result = $this->connection
->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args);
}
else {
$result = $this->connection
->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid DESC", $args);
}
if ($source = $result
->fetchField()) {
$this->lookupMap[$langcode][$source] = $path;
}
else {
// We can't record anything into $map because we do not have a valid
// index and there is no need because we have not learned anything
// about any Drupal path. Thus cache to $no_source.
$this->noSource[$langcode][$path] = TRUE;
}
}
return $source;
}
return FALSE;
}