function acquia_search_get_core_service in Acquia Search 2.x
Instantiates the PreferredSearchCoreService class.
The PreferredSearchCoreService class, helps to determines which search core should be used and whether it is available within the subscription.
Return value
\Drupal\acquia_search\PreferredSearchCoreService Preferred Search Core Service.
6 calls to acquia_search_get_core_service()
- AcquiaSearchCommands::__construct in src/
Commands/ AcquiaSearchCommands.php - AcquiaSearchCommands constructor.
- acquia_search_get_read_only_mode_warning in ./
acquia_search.module - Returns formatted message about read-only mode.
- acquia_search_search_api_server_load in ./
acquia_search.module - Implements hook_search_api_server_load().
- acquia_search_should_set_read_only_mode in ./
acquia_search.module - Determine if we should enforce read-only mode.
- SearchApiSolrAcquiaConnector::defaultConfiguration in src/
Plugin/ SolrConnector/ SearchApiSolrAcquiaConnector.php - Gets default configuration for this plugin.
File
- ./
acquia_search.module, line 550 - Integration between Acquia Drupal and Acquia's hosted solr search service.
Code
function acquia_search_get_core_service() {
static $core_service;
if (isset($core_service)) {
return $core_service;
}
$storage = new Storage();
$acquia_identifier = $storage
->getIdentifier();
$ah_env = isset($_ENV['AH_SITE_ENVIRONMENT']) ? $_ENV['AH_SITE_ENVIRONMENT'] : '';
$ah_site_name = isset($_ENV['AH_SITE_NAME']) ? $_ENV['AH_SITE_NAME'] : '';
$ah_site_group = isset($_ENV['AH_SITE_GROUP']) ? $_ENV['AH_SITE_GROUP'] : '';
$conf_path = \Drupal::service('site.path');
$sites_foldername = substr($conf_path, strrpos($conf_path, '/') + 1);
$ah_db_name = '';
if ($ah_env && $ah_site_name && $ah_site_group) {
$options = Database::getConnection()
->getConnectionOptions();
$ah_db_name = $options['database'];
}
$subscription = \Drupal::state()
->get('acquia_subscription_data');
$available_cores = [];
if (!empty($subscription['heartbeat_data']['search_cores'])) {
$available_cores = $subscription['heartbeat_data']['search_cores'];
}
$search_v3_cores = acquia_search_get_v3_cores($acquia_identifier);
$available_cores = array_merge($available_cores, $search_v3_cores);
$core_service = new PreferredSearchCoreService($acquia_identifier, $ah_env, $sites_foldername, $ah_db_name, $available_cores);
return $core_service;
}