patch add custom field types

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2013-03-12 19:15:12 +01:00
parent 6a402551d7
commit c9912105d5
4 changed files with 336 additions and 24 deletions

View File

@@ -143,3 +143,81 @@ function search_api_solr_cron() {
}
}
}
/**
* Returns either all dynamic field types, or a specific one.
*
* @param $type
* If specified, the type whose definition should be returned.
*
* @return array
* If $type was not given, an array containing all custom dynamic fields, in
* the format specified by hook_search_api_solr_dynamic_field_info().
* Otherwise, the definition for the given type, or NULL if it is unknown.
*
* @see hook_search_api_solr_dynamic_field_info().
*/
function search_api_solr_get_dynamic_field_info($type = NULL) {
$types = &drupal_static(__FUNCTION__);
if (!isset($types)) {
$types = module_invoke_all('search_api_solr_dynamic_field_info');
$types = $types ? $types : array();
drupal_alter('search_api_solr_dynamic_field_info', $types);
}
if (isset($type)) {
return isset($types[$type]) ? $types[$type] : NULL;
}
return $types;
}
/**
* Implements hook_search_api_solr_dynamic_field_info().
*/
function search_api_solr_search_api_solr_dynamic_field_info() {
return array(
'text' => array(
'prefix' => 'tm',
'always multiValued' => TRUE,
),
'tokens' => array(
'prefix' => 'tm',
'always multiValued' => TRUE,
),
'string' => array(
'prefix' => 's',
'always multiValued' => FALSE,
),
'integer' => array(
'prefix' => 'i',
'always multiValued' => FALSE,
),
'decimal' => array(
'prefix' => 'f',
'always multiValued' => FALSE,
),
'date' => array(
'prefix' => 'd',
'always multiValued' => FALSE,
),
'duration' => array(
'i',
'always multiValued' => FALSE,
),
'boolean' => array(
'b',
'always multiValued' => FALSE,
),
'uri' => array(
's',
'always multiValued' => FALSE,
),
'location' => array(
'loc',
'always multiValued' => FALSE,
),
'geohash' => array(
'geohash',
'always multiValued' => FALSE,
),
);
}