pigeon_paywall-1.0.x-dev/pigeon_paywall.module
pigeon_paywall.module
<?php
/**
* @file
* Primary hook implementations for the Pigeon Paywall module.
*/
/**
* Implements hook_library_info_alter().
*/
function pigeon_paywall_library_info_alter(array &$libraries, $extension) {
// Change the URL of the remote JS to use the hostname/subdomain defined in
// the settings.
if ($extension === 'pigeon_paywall') {
if (isset($libraries['dependencies']['js']['pigeon.js'])) {
$subdomain = \Drupal::config('pigeon_paywall.settings')->get('subdomain');
if (!empty($subdomain)) {
// Just use the exiting JS library definition, to make this simpler.
$definition = $libraries['dependencies']['js']['pigeon.js'];
$libraries['dependencies']['js'] = [
'//' . $subdomain . '/c/assets/pigeon.js' => $definition,
];
}
}
}
}
