public function AcquiaSearchSolrApi::getDatabaseRole in Acquia Connector 7.3
Returns the name of the Acquia "DB Role".
Acquia "DB Role" is in use when running inside an Acquia environment.
Parameters
array $databases: List of available databases.
string $ah_db_name: Current database name.
Return value
string Database role.
1 call to AcquiaSearchSolrApi::getDatabaseRole()
- AcquiaSearchSolrApi::getPreferredIndexService in acquia_search/
includes/ AcquiaSearchSolrApi.php - Returns preferred search index service.
File
- acquia_search/
includes/ AcquiaSearchSolrApi.php, line 204
Class
- AcquiaSearchSolrApi
- Class AcquiaSearchApi.
Code
public function getDatabaseRole(array $databases, string $ah_db_name) {
// Ignore the "default" connection, because even though it may match the
// currently-used DB connection, this entry always exists and its key
// won't match the AH "DB Role".
$filter = function ($role) {
return $role !== 'default';
};
$databases = array_filter($databases, $filter, ARRAY_FILTER_USE_KEY);
// Scan all the available Databases and look for the currently-used DB name.
foreach ($databases as $database_role => $databases_list) {
if ($databases_list['default']['database'] == $ah_db_name) {
$database_role = $this
->sanitizeDatabaseRoleName($database_role);
return $database_role;
}
}
return '';
}