protected function SearchApiCombinedEntityDataSourceController::getCallingIndex in Search API 7
Retrieves the index for which the current method was called.
Very ugly method which uses the stack trace to find the right object.
Return value
SearchApiIndex The active index.
Throws
SearchApiException Thrown if the active index could not be determined.
1 call to SearchApiCombinedEntityDataSourceController::getCallingIndex()
- SearchApiCombinedEntityDataSourceController::getEntityTypes in includes/
datasource_multiple.inc - Returns the entity types for which this datasource is configured.
File
- includes/
datasource_multiple.inc, line 300 - Contains SearchApiCombinedEntityDataSourceController.
Class
- SearchApiCombinedEntityDataSourceController
- Provides a datasource for indexing multiple types of entities.
Code
protected function getCallingIndex() {
foreach (debug_backtrace() as $trace) {
if (isset($trace['object']) && $trace['object'] instanceof SearchApiIndex) {
return $trace['object'];
}
}
// If there's only a single index on the site, it's also easy.
$indexes = search_api_index_load_multiple(FALSE);
if (count($indexes) === 1) {
return reset($indexes);
}
throw new SearchApiException('Could not determine the active index of the datasource.');
}