function search_api_get_datasource_controller in Search API 7
Get a data source controller object for the specified type.
Parameters
$type: The type whose data source controller should be returned.
Return value
SearchApiDataSourceControllerInterface The type's data source controller.
Throws
SearchApiException If the type is unknown or specifies an invalid data source controller.
8 calls to search_api_get_datasource_controller()
- SearchApiIndex::datasource in includes/
index_entity.inc - Get the controller object of the data source used by this index.
- SearchApiUnitTest::checkEntityDatasource in ./
search_api.test - Tests the entity datasource controller and its bundle setting.
- search_api_admin_add_index in ./
search_api.admin.inc - Form constructor for adding an index.
- search_api_admin_add_index_submit in ./
search_api.admin.inc - Form submission handler for search_api_admin_add_index().
- search_api_admin_add_index_validate in ./
search_api.admin.inc - Form validation handler for search_api_admin_add_index().
2 string references to 'search_api_get_datasource_controller'
- SearchApiUnitTest::checkEntityDatasource in ./
search_api.test - Tests the entity datasource controller and its bundle setting.
- search_api_field_attach_rename_bundle in ./
search_api.module - Implements hook_field_attach_rename_bundle().
File
- ./
search_api.module, line 2136 - Provides a flexible framework for implementing search services.
Code
function search_api_get_datasource_controller($type) {
$datasources =& drupal_static(__FUNCTION__, array());
if (empty($datasources[$type])) {
$info = search_api_get_item_type_info($type);
if (isset($info['datasource controller']) && class_exists($info['datasource controller'])) {
$datasources[$type] = new $info['datasource controller']($type);
}
if (empty($datasources[$type]) || !$datasources[$type] instanceof SearchApiDataSourceControllerInterface) {
unset($datasources[$type]);
throw new SearchApiException(t('Unknown or invalid item type @type.', array(
'@type' => $type,
)));
}
}
return $datasources[$type];
}