You are here

function gardens_site_data_from_multi_site_config in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 acsf_init/lib/sites/g/sites.inc \gardens_site_data_from_multi_site_config()

Returns data for the specified domains using hosting's php interface.

Parameters

array $domains: The domain names to look up in the domain registry.

Return value

array An array keyed by the specified domains, whose values are site data arrays or 0 if no site was found for the given domain.

1 call to gardens_site_data_from_multi_site_config()
gardens_site_data_refresh_one in acsf_init/lib/sites/g/sites.inc
Returns data for a single domain.

File

acsf_init/lib/sites/g/sites.inc, line 521
ACSF helper functions for Drupal's multi-site directory aliasing feature.

Code

function gardens_site_data_from_multi_site_config(array $domains) {
  $data = [];
  $config = Config::getInstance();
  foreach ($domains as $domain) {
    $domain = trim($domain);
    if ($config) {

      // Site config returns an associative array representation of one
      // site object, selected by domain.
      $found_site = $config
        ->siteConfig($domain);

      // Shared config returns an associative array with every key except sites.
      $global_map_data = $config
        ->sharedConfig();
    }

    // In case of missing data, set the results to zero and report the failure.
    if (empty($found_site) || empty($global_map_data)) {
      $data[$domain] = 0;
      if (class_exists('Drupal') && \Drupal::hasService('logger.factory')) {
        \Drupal::logger('acsf')
          ->alert('Unable to extract site data for site @site.', [
          '@site' => $domain,
        ]);
      }
      elseif (function_exists('syslog')) {
        syslog(LOG_ERR, sprintf('Unable to extract data for site %s.', $domain));
      }
    }
    else {
      $data[$domain] = gardens_site_data_build_data($found_site, $global_map_data);
    }
  }
  return $data;
}