You are here

function livechat_attach_js_settings in LiveChat 8

Same name and namespace in other branches
  1. 8.2 livechat.module \livechat_attach_js_settings()

Return settings for attaching LiveChat tracking code.

Parameters

string $license: LiveChat account license number.

string $group_id: Id of the website for multi-site.

Return value

array

1 call to livechat_attach_js_settings()
livechat_page_attachments in ./livechat.module
Implements hook_page_attachments().

File

./livechat.module, line 68
LiveChat module.

Code

function livechat_attach_js_settings($license, $group_id) {
  $settings = [];
  if (!empty($license)) {

    // Allow modules to add custom parameters and visitor information.
    $params = [];
    $visitor = [];
    \Drupal::moduleHandler()
      ->alter('livechat', $params, $visitor);
    $settings = [
      'license' => $license,
      'params' => $params,
      'visitor' => $visitor,
    ];

    // Add in the group id if it has been set.
    if (!empty($group_id)) {
      $settings['LiveChat']['group'] = $group_id;
    }
  }
  return $settings;
}