You are here

protected function AcquiaPurgeHostingInfo::domainsNormalize in Acquia Purge 7

Normalize $this->domains, so that it contains no:

  • uppercase strings.
  • empty strings
  • asterisks
  • duplicates
  • leading or traling spaces
1 call to AcquiaPurgeHostingInfo::domainsNormalize()
AcquiaPurgeHostingInfo::domains in lib/AcquiaPurgeHostingInfo.php
Initialize $this->domains.

File

lib/AcquiaPurgeHostingInfo.php, line 196
Contains AcquiaPurgeHostingInfo.

Class

AcquiaPurgeHostingInfo
Provides technical information accessors for the Acquia Cloud environment.

Code

protected function domainsNormalize() {
  if (!function_exists('drupal_strtolower')) {
    include_once DRUPAL_ROOT . '/includes/unicode.inc';
  }

  // Normalize all domains.
  $domains = array();
  foreach ($this->domains as $domain) {
    $domain = trim(drupal_strtolower($domain));
    $domain = str_replace('.*.', '', $domain);
    $domain = str_replace('*.', '', $domain);
    $domain = str_replace('*', '', $domain);
    if (!empty($domain) && !in_array($domain, $domains)) {
      $domains[] = $domain;
    }
  }

  // Remove the acquia-sites.com domain when there's more then just one domain
  // name discovered, if not, we're likely running on a dev/stage environment.
  if (count($domains) > 1) {
    foreach ($domains as $i => $domain) {
      if (strpos($domain, 'acquia-sites.com') !== FALSE) {
        unset($domains[$i]);
      }
    }
  }
  $this->domains = $domains;
}