You are here

function gardens_site_data_shared_creds_get in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 acsf_init/lib/sites/g/sites.inc \gardens_site_data_shared_creds_get()

Returns the shared credentials.

Parameters

string $site: The hosting sitegroup name.

string $env: The hosting environment name.

Return value

Acquia\SimpleRest\SimpleRestCreds The credentials.

Throws

Exception If the credentials cannot be read for any reason.

1 call to gardens_site_data_shared_creds_get()
gardens_site_data_alert_send in acsf_init/lib/sites/g/sites.inc
Alerts the Site Factory on possible sites.json issues.

File

acsf_init/lib/sites/g/sites.inc, line 792
ACSF helper functions for Drupal's multi-site directory aliasing feature.

Code

function gardens_site_data_shared_creds_get($site, $env) {
  $ini_file = sprintf('/mnt/files/%s.%s/nobackup/sf_shared_creds.ini', $site, $env);
  if (file_exists($ini_file)) {
    $data = parse_ini_file($ini_file, TRUE);
    if (!empty($data) && !empty($data['gardener'])) {
      return new SimpleRestCreds($data['gardener']['username'], $data['gardener']['password'], $data['gardener']['url']);
    }
  }
  throw new Exception(sprintf('Unable to read credentials from %s.', $ini_file));
}