function sarnia_sarnia_solr_service_schema in Sarnia 7
Implements hook_sarnia_solr_service_schema().
2 calls to sarnia_sarnia_solr_service_schema()
- sarnia_schema_rule_form in ./
sarnia.rules.inc - Administration form for rules.
- sarnia_schema_rule_list in ./
sarnia.rules.inc
File
- ./
sarnia.module, line 1048
Code
function sarnia_sarnia_solr_service_schema($conditions = array()) {
$conditions += array(
'enabled' => TRUE,
);
$query = db_select('sarnia_solr_service_schema', 'ss')
->fields('ss')
->orderBy('ss.behavior', 'ASC');
foreach ($conditions as $field => $value) {
$query
->condition('ss.' . $field, $value);
}
// Sort server-specific rules first.
$query
->orderBy('ss.search_api_server', 'DESC');
// Sort name matches first, then dynamicBase, then type.
$rule_order = $query
->addExpression("ss.match_type = 'name'", 'sort_1');
$query
->orderBy($rule_order, 'DESC');
$rule_order = $query
->addExpression("ss.match_type = 'dynamicBase'", 'sort_2');
$query
->orderBy($rule_order, 'DESC');
$rule_order = $query
->addExpression("ss.match_type = 'type'", 'sort_3');
$query
->orderBy($rule_order, 'DESC');
return $query
->execute()
->fetchAll();
}