/**
  * Get Acquia subscription from Acquia Network.
  *
  * @param string $id Network ID
  * @param string $key Network Key
  * @param array $body
  *   (optional)
  *
  * @return array|false or throw Exception
  *
  * @throws \Exception
  */
 public function getSubscription($id, $key, array $body = array())
 {
     $body['identifier'] = $id;
     // There is an identifier and key, so attempt communication.
     $subscription = array();
     $subscription['timestamp'] = REQUEST_TIME;
     // Include version number information.
     acquia_connector_load_versions();
     if (IS_ACQUIA_DRUPAL) {
         $body['version'] = ACQUIA_DRUPAL_VERSION;
         $body['series'] = ACQUIA_DRUPAL_SERIES;
         $body['branch'] = ACQUIA_DRUPAL_BRANCH;
         $body['revision'] = ACQUIA_DRUPAL_REVISION;
     }
     // Include Acquia Search for Search API module version number.
     if (\Drupal::moduleHandler()->moduleExists('acquia_search')) {
         foreach (array('acquia_search', 'search_api', 'search_api_solr') as $name) {
             $info = system_get_info('module', $name);
             // Send the version, or at least the core compatibility as a fallback.
             $body['search_version'][$name] = isset($info['version']) ? (string) $info['version'] : (string) $info['core'];
         }
     }
     try {
         $response = $this->nspiCall('/agent-api/subscription', $body);
         if (!empty($response['result']['authenticator']) && $this->validateResponse($key, $response['result'], $response['authenticator'])) {
             $subscription += $response['result']['body'];
             // Subscription activated.
             if (is_numeric($this->config->get('subscription_data')) && is_array($response['result']['body'])) {
                 \Drupal::moduleHandler()->invokeAll('acquia_subscription_status', [$subscription]);
                 \Drupal::configFactory()->getEditable('acquia_connector.settings')->set('subscription_data', $subscription)->save();
             }
             return $subscription;
         }
     } catch (ConnectorException $e) {
         drupal_set_message(t('Error occurred while retrieving Acquia subscription information. See logs for details.'), 'error');
         if ($e->isCustomized()) {
             \Drupal::logger('acquia connector')->error($e->getCustomMessage() . '. Response data: @data', array('@data' => json_encode($e->getAllCustomMessages())));
         } else {
             \Drupal::logger('acquia connector')->error($e->getMessage());
         }
         throw $e;
     }
     return FALSE;
 }
 /**
  * Attempt to determine the version of Drupal being used.
  * Note, there is better information on this in the common.inc file.
  *
  * @return array
  *    An array containing some detail about the version
  */
 private function getVersionInfo()
 {
     $store = $this->dataStoreGet(array('platform'));
     $server = !empty($store) && isset($store['platform']) ? $store['platform']['php_quantum']['SERVER'] : \Drupal::request()->server->all();
     $ver = array();
     $ver['base_version'] = \Drupal::VERSION;
     $install_root = $server['DOCUMENT_ROOT'] . base_path();
     $ver['distribution'] = '';
     // Determine if this puppy is Acquia Drupal
     acquia_connector_load_versions();
     if (IS_ACQUIA_DRUPAL) {
         $ver['distribution'] = 'Acquia Drupal';
         $ver['ad']['version'] = ACQUIA_DRUPAL_VERSION;
         $ver['ad']['series'] = ACQUIA_DRUPAL_SERIES;
         $ver['ad']['branch'] = ACQUIA_DRUPAL_BRANCH;
         $ver['ad']['revision'] = ACQUIA_DRUPAL_REVISION;
     }
     // @todo: Review all D8 distributions!
     // Determine if we are looking at Pressflow
     if (defined('CACHE_EXTERNAL')) {
         $ver['distribution'] = 'Pressflow';
         $press_version_file = $install_root . './PRESSFLOW.txt';
         if (is_file($press_version_file)) {
             $ver['pr']['version'] = trim(file_get_contents($press_version_file));
         }
     } elseif (is_dir($install_root . '/profiles/openatrium')) {
         $ver['distribution'] = 'Open Atrium';
         $version_file = $install_root . 'profiles/openatrium/VERSION.txt';
         if (is_file($version_file)) {
             $ver['oa']['version'] = trim(file_get_contents($version_file));
         }
     } elseif (is_dir($install_root . '/profiles/commons')) {
         $ver['distribution'] = 'Commons';
     } elseif (is_dir($install_root . '/profiles/cod')) {
         $ver['distribution'] = 'COD';
     }
     return $ver;
 }