function search_api_solr_get_servers in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 search_api_solr.module \search_api_solr_get_servers()
- 8.2 search_api_solr.module \search_api_solr_get_servers()
Get all Search API servers that use a Solr backend.
Parameters
bool $only_active:
Return value
\Drupal\search_api\ServerInterface[]
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\search_api\SearchApiException
6 calls to search_api_solr_get_servers()
- ConfigSubscriber::onConfigSave in src/
EventSubscriber/ ConfigSubscriber.php - Installs all available Solr Field Types for a new language.
- search_api_solr_cron in ./
search_api_solr.module - Implements hook_cron().
- search_api_solr_requirements in ./
search_api_solr.install - Implements hook_requirements().
- search_api_solr_uninstall in ./
search_api_solr.install - Implements hook_uninstall().
- SolrCommandHelper::finalizeIndexCommand in src/
Utility/ SolrCommandHelper.php - Finalizes one ore more indexes.
File
- ./
search_api_solr.module, line 589
Code
function search_api_solr_get_servers($only_active = TRUE) {
$solr_servers = [];
$storage = \Drupal::entityTypeManager()
->getStorage('search_api_server');
/** @var \Drupal\search_api\ServerInterface[] $servers */
$servers = $only_active ? $storage
->loadByProperties([
'status' => TRUE,
]) : $storage
->loadMultiple();
foreach ($servers as $server) {
if ($server
->hasValidBackend() && $server
->getBackend() instanceof SolrBackendInterface) {
$solr_servers[$server
->id()] = $server;
}
}
return $solr_servers;
}