function search_api_solr_get_active_servers in Search API Solr 8
Gets all active Solr servers.
Return value
\Drupal\search_api\Entity\Server[] All active Solr servers keyed by ids.
1 call to search_api_solr_get_active_servers()
- search_api_solr_requirements in ./
search_api_solr.install - Implements hook_requirements().
File
- ./
search_api_solr.install, line 118
Code
function search_api_solr_get_active_servers() {
$config_factory = \Drupal::configFactory();
$servers = [];
foreach ($config_factory
->listAll('search_api.server.') as $server_config_name) {
$server_id = $config_factory
->get($server_config_name)
->get('id');
$server = Server::load($server_id);
// Covers search_api_solr_multilingual, too.
if ($server
->getBackend() instanceof SolrBackendInterface && $server
->status()) {
$servers[$server_id] = $server;
}
}
return $servers;
}