protected function AcquiaPurgeHostingInfo::domainsAddFromAcquiaCloud in Acquia Purge 7
Source the domain names configured on Acquia Cloud.
1 call to AcquiaPurgeHostingInfo::domainsAddFromAcquiaCloud()
- AcquiaPurgeHostingInfo::domains in lib/
AcquiaPurgeHostingInfo.php - Initialize $this->domains.
File
- lib/
AcquiaPurgeHostingInfo.php, line 315 - Contains AcquiaPurgeHostingInfo.
Class
- AcquiaPurgeHostingInfo
- Provides technical information accessors for the Acquia Cloud environment.
Code
protected function domainsAddFromAcquiaCloud() {
$detected_domains = array();
// Source the domain names from config.json.
$config_json = '/var/www/site-php/' . $this->siteName . '/config.json';
if (file_exists($config_json) && is_readable($config_json)) {
$config = json_decode(file_get_contents($config_json, TRUE), TRUE);
if (isset($config['domains'])) {
if (is_array($config['domains'])) {
foreach ($config['domains'] as $detected_domain) {
$detected_domains[] = (string) $detected_domain;
}
}
}
}
elseif (file_exists('/etc/apache2/conf.d')) {
$server_name = shell_exec("grep -r 'ServerName' /etc/apache2/conf.d/" . $this->siteName . "-*.conf");
foreach (explode('ServerName', $server_name) as $testable) {
foreach (explode(' ', trim($testable)) as $domain) {
$detected_domains[] = $domain;
}
}
$server_alias = shell_exec("grep -r 'ServerAlias' /etc/apache2/conf.d/" . $this->siteName . "-*.conf");
foreach (explode('ServerAlias', $server_alias) as $testable) {
foreach (explode(' ', trim($testable)) as $domain) {
$detected_domains[] = $domain;
}
}
}
// Remove the amazonaws.com domain as we don't want that one purged.
if (count($detected_domains)) {
foreach ($detected_domains as $i => $detected_domain) {
if (strpos($detected_domain, 'amazonaws.com') !== FALSE) {
unset($detected_domains[$i]);
}
}
}
// Register all detected domain names.
foreach ($detected_domains as $i => $detected_domain) {
$this->domains[] = $detected_domain;
}
}