class AcsfConfigDefault in Acquia Cloud Site Factory Connector 8.2
Same name and namespace in other branches
- 8 src/AcsfConfigDefault.php \Drupal\acsf\AcsfConfigDefault
Creates a config object using our custom INI file.
Hierarchy
- class \Drupal\acsf\AcsfConfig
- class \Drupal\acsf\AcsfConfigDefault
Expanded class hierarchy of AcsfConfigDefault
1 file declares its use of AcsfConfigDefault
- AcsfExtraCommands.php in src/
Commands/ AcsfExtraCommands.php
File
- src/
AcsfConfigDefault.php, line 8
Namespace
Drupal\acsfView source
class AcsfConfigDefault extends AcsfConfig {
/**
* Keep the values from the config file in a shared static cache.
*
* @var object
*/
protected static $cacheDefault;
/**
* Implements AcsfConfig::loadConfig().
*/
protected function loadConfig() {
// If the cache is empty, we haven't loaded the config file yet.
if (empty(self::$cacheDefault)) {
self::$cacheDefault = new \stdClass();
$this
->loadIniFile();
}
$this->url = self::$cacheDefault->url;
$this->username = self::$cacheDefault->username;
$this->password = self::$cacheDefault->password;
$this->urlSuffix = self::$cacheDefault->urlSuffix;
$this->sourceUrl = self::$cacheDefault->sourceUrl;
}
/**
* 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
*/
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 = '';
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcsfConfig:: |
protected | property | An optional Acquia Hosting environment. | |
AcsfConfig:: |
protected | property | An optional Acquia Hosting sitegroup. | |
AcsfConfig:: |
protected | property | The password of the remote service. | |
AcsfConfig:: |
protected | property | The optional source URL of the factory which our sites were staged from. | |
AcsfConfig:: |
protected | property | The URL of the remote service (factory). | |
AcsfConfig:: |
protected | property | The optional signup suffix of the Factory. See getUrlSuffix() for caveat. | |
AcsfConfig:: |
protected | property | The username of the remote service. | |
AcsfConfig:: |
public | function | Retrieves the config password. | |
AcsfConfig:: |
public | function | Retrieves the URL of the production factory. | |
AcsfConfig:: |
public | function | Retrieves the URL of the remote service (factory). | |
AcsfConfig:: |
public | function | Retrieves the domain suffix used for sites hosted on this ACSF environment. | |
AcsfConfig:: |
public | function | Retrieves the config username. | |
AcsfConfig:: |
public | function | Constructor. | |
AcsfConfigDefault:: |
protected static | property | Keep the values from the config file in a shared static cache. | |
AcsfConfigDefault:: |
protected | function |
Implements AcsfConfig::loadConfig(). Overrides AcsfConfig:: |
1 |
AcsfConfigDefault:: |
protected | function | Implements AcsfConfig::loadConfig(). |