You are here

protected function AcsfConfigDefault::loadIniFile in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 src/AcsfConfigDefault.php \Drupal\acsf\AcsfConfigDefault::loadIniFile()

Implements AcsfConfig::loadConfig().

The cred file location will match the directory structure of an AH site: /mnt/www/html/[site].[env]/docroot will have a credential file at /mnt/files/[site].[env]/nobackup/sf_shared_creds.ini, using normal INI format:

[gardener] url = "http://gardener.[stage].acquia-sites.com" username = "acquiagardensrpc" password = "[password]" url_suffix = "[stage].acquia-sites.com" ; The url_suffix is only present for staged sites. Also: see getUrlSuffix()

Throws

AcsfConfigMissingCredsException

1 call to AcsfConfigDefault::loadIniFile()
AcsfConfigDefault::loadConfig in src/AcsfConfigDefault.php
Implements AcsfConfig::loadConfig().

File

src/AcsfConfigDefault.php, line 51

Class

AcsfConfigDefault
Creates a config object using our custom INI file.

Namespace

Drupal\acsf

Code

protected function loadIniFile() {
  $ini_file = sprintf('/mnt/files/%s.%s/nobackup/sf_shared_creds.ini', $this->ahSite, $this->ahEnv);
  $acsf_shared_creds = parse_ini_file($ini_file, TRUE);
  if (empty($acsf_shared_creds['gardener'])) {
    throw new AcsfConfigMissingCredsException(sprintf('Shared credential file not found in /mnt/files/%s.%s/nobackup/.', $this->ahSite, $this->ahEnv));
  }

  // Set the cached values for subsequent usage.
  self::$cacheDefault->url = $acsf_shared_creds['gardener']['url'];
  self::$cacheDefault->username = $acsf_shared_creds['gardener']['username'];
  self::$cacheDefault->password = $acsf_shared_creds['gardener']['password'];
  if (isset($acsf_shared_creds['gardener']['url_suffix'])) {
    self::$cacheDefault->urlSuffix = $acsf_shared_creds['gardener']['url_suffix'];
  }
  else {
    self::$cacheDefault->urlSuffix = '';
  }
  if (isset($acsf_shared_creds['gardener']['source_url'])) {
    self::$cacheDefault->sourceUrl = $acsf_shared_creds['gardener']['source_url'];
  }
  else {
    self::$cacheDefault->sourceUrl = '';
  }
}