You are here

public function AcquiaPurgeHostingInfo::__construct in Acquia Purge 7

Constructs a AcquiaPurgeHostingInfo object.

File

lib/AcquiaPurgeHostingInfo.php, line 86
Contains AcquiaPurgeHostingInfo.

Class

AcquiaPurgeHostingInfo
Provides technical information accessors for the Acquia Cloud environment.

Code

public function __construct() {

  // Fetch the sitename and sitegroup from the environment.
  if (isset($_ENV['AH_SITE_ENVIRONMENT']) && !empty($_ENV['AH_SITE_ENVIRONMENT'])) {
    $this->siteEnvironment = $_ENV['AH_SITE_ENVIRONMENT'];
  }
  if (isset($_ENV['AH_SITE_NAME']) && !empty($_ENV['AH_SITE_NAME'])) {
    $this->siteName = $_ENV['AH_SITE_NAME'];
  }
  if (isset($_ENV['AH_SITE_GROUP']) && !empty($_ENV['AH_SITE_GROUP'])) {
    $this->siteGroup = $_ENV['AH_SITE_GROUP'];
  }
  if (!empty($GLOBALS['gardens_site_settings'])) {
    $this->siteEnvironment = $GLOBALS['gardens_site_settings']['env'];
    $this->siteGroup = $GLOBALS['gardens_site_settings']['site'];
    $this->siteName = $this->siteGroup . '.' . $this->siteEnvironment;
  }

  // Determine the balancer token and IP addresses.
  if (is_array($reverse_proxies = variable_get('reverse_proxies'))) {
    foreach ($reverse_proxies as $reverse_proxy) {
      if ($reverse_proxy && strpos($reverse_proxy, '.')) {
        $this->balancerAddresses[] = $reverse_proxy;
      }
    }
  }
  $this->balancerToken = $this->siteName;
  if ($token_configured = _acquia_purge_variable('acquia_purge_token')) {
    $this->balancerToken = (string) trim($token_configured);
  }

  // Determine what the page cache is operating on.
  $cache = variable_get('cache_default_class', $this->pageCacheBackend);
  $this->pageCacheBackend = variable_get('cache_class_cache_page', $cache);

  // Determine what the protocol schemes are based on settings.
  if (_acquia_purge_variable('acquia_purge_http')) {
    $this->schemes[] = 'http';
  }
  if (_acquia_purge_variable('acquia_purge_https')) {
    $this->schemes[] = 'https';
  }

  // Determine whether memcached is powering Drupal's caches or not.
  if (_acquia_purge_variable('acquia_purge_memcache')) {
    if ($cache == 'MemCacheDrupal' && function_exists('dmemcache_get')) {
      $this->isMemcachedUsed = TRUE;
    }
  }

  // Test the gathered information to determine if this is/isn't Acquia Cloud.
  $this->isThisAcquiaCloud = count($this->balancerAddresses) && $this->balancerToken && $this->siteEnvironment && $this->siteName && $this->siteGroup && function_exists('curl_init');

  // Gather the domains to be purged.
  $this
    ->domains();
}