1 node.module _node_rankings(SelectQueryExtender $query)

Gathers the rankings from the the hook_ranking implementations.

Parameters

SearchQuery|SelectQueryExtender $query: A query object that has been extended with the Search DB Extender.

File

core/modules/node/node.module, line 1273
The core module that allows content to be submitted to the site.

Code

function _node_rankings(SelectQueryExtender $query) {
  if ($ranking = module_invoke_all('ranking')) {
    $tables = &$query->getTables();
    $config = config('search.settings');
    foreach ($ranking as $rank => $values) {
      if ($node_rank = $config->get('node_rank_' . $rank)) {
        // If the table defined in the ranking isn't already joined, then add it.
        if (isset($values['join']) && !isset($tables[$values['join']['alias']])) {
          $query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']);
        }
        $arguments = isset($values['arguments']) ? $values['arguments'] : array();
        $query->addScore($values['score'], $arguments, $node_rank);
      }
    }
  }
}