BackendTrait.php in Search API Solr 4.x
File
src/Plugin/search_api_autocomplete/suggester/BackendTrait.php
View source
<?php
namespace Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\LoggerTrait;
use Drupal\search_api_solr\SolrAutocompleteInterface;
trait BackendTrait {
use LoggerTrait;
protected static function getBackend(IndexInterface $index) {
try {
if ($index
->hasValidServer() && ($server = $index
->getServerInstance()) && ($backend = $server
->getBackend()) && $backend instanceof SolrAutocompleteInterface && $server
->supportsFeature('search_api_autocomplete')) {
return $backend;
}
} catch (\Exception $e) {
watchdog_exception('search_api', $e);
}
return NULL;
}
}
Traits
Name |
Description |
BackendTrait |
Provides a helper method for loading the search backend. |