You are here

function _path_redirect_uasort in Path redirect 6

uasort callback; Compare redirects based on language neutrality and rids.

1 string reference to '_path_redirect_uasort'
path_redirect_load_by_source in ./path_redirect.module
Load a redirect by incoming path and language.

File

./path_redirect.module, line 450

Code

function _path_redirect_uasort($a, $b) {
  $a_weight = isset($a['weight']) ? $a['weight'] : 0;
  $b_weight = isset($b['weight']) ? $b['weight'] : 0;
  if ($a_weight != $b_weight) {

    // First sort by weight (case sensitivity).
    return $a_weight > $b_weight;
  }
  elseif ($a['language'] != $b['language']) {

    // Then sort by language specific over language neutral.
    return $a['language'] == '';
  }
  elseif (empty($a['source_query']) != empty($b['source_query'])) {

    // Then sort by redirects that do not have query strings over ones that do.
    return empty($a['source_query']);
  }
  else {

    // Lastly sort by the highest redirect ID.
    return $a['rid'] < $b['rid'];
  }
}