You are here

function hubspot_library_info_build in HubSpot 3.x

Same name and namespace in other branches
  1. 8 hubspot.module \hubspot_library_info_build()

Implements hook_library_info_build().

Creates library info with dynamic script file name.

File

./hubspot.module, line 118
Sends Webform results to HubSpot's Forms API.

Code

function hubspot_library_info_build() {
  $portal_id = \Drupal::config('hubspot.settings')
    ->get('hubspot_portal_id');
  $libraries = [];

  // Add a library whose information changes depending on certain conditions.
  $libraries['hubspot.code_tracking'] = [
    'dependencies' => [
      'core/jquery',
      'core/drupalSettings',
    ],
  ];
  $libraries['hubspot.code_tracking'] += [
    'js' => [
      'https://js.hs-scripts.com/' . $portal_id . '.js' => [
        'type' => 'external',
        'attributes' => [
          'id' => "hs-script-loader",
          'defer' => TRUE,
          'async' => TRUE,
        ],
      ],
    ],
  ];
  return $libraries;
}