You are here

function _mailchimp_get_user_agent in Mailchimp 2.x

Same name and namespace in other branches
  1. 8 mailchimp.module \_mailchimp_get_user_agent()
  2. 7.5 mailchimp.module \_mailchimp_get_user_agent()
  3. 7.4 mailchimp.module \_mailchimp_get_user_agent()

Gets the user agent string for this installation of Mailchimp.

Return value

string The user agent string.

File

./mailchimp.module, line 57
Mailchimp module.

Code

function _mailchimp_get_user_agent() {
  $version = '8.x-1.x';
  if (\Drupal::moduleHandler()
    ->moduleExists('system')) {

    /** @var \Drupal\Core\Extension\ModuleExtensionList $extension_list */
    $extension_list = \Drupal::service('extension.list.module');
    $info = $extension_list
      ->getExtensionInfo('mailchimp');
    if (!empty($info['version'])) {
      $version = $info['version'];
    }
  }
  $user_agent = "DrupalMailchimp/{$version} " . \GuzzleHttp\default_user_agent();
  return $user_agent;
}