You are here

function bootstrap_library_library_info_build in Bootstrap Library 8

Implements hook_library_info_build().

File

./bootstrap_library.module, line 53
Primarily Drupal hooks.

Code

function bootstrap_library_library_info_build() {
  $libraries = [];
  $config = \Drupal::config('bootstrap_library.settings');
  $cdn = $config
    ->get('cdn.bootstrap');
  if ($cdn) {
    $data = $config
      ->get('cdn.options');
    $cdn_options = json_decode($data);
    $list = _bootstrap_library_object_to_array($cdn_options->bootstrap);
    if (!is_array($list[$cdn]['js'])) {
      $list[$cdn]['js'] = array(
        $list[$cdn]['js'],
      );
    }
    $css_uri = $list[$cdn]['css'];
    $libraries['bootstrap-cdn'] = [
      'dependencies' => [
        'core/jquery',
      ],
    ];
    $libraries['bootstrap-cdn']['css']['base'][$css_uri] = [
      'type' => 'external',
    ];
    foreach ($list[$cdn]['js'] as $js_uri) {
      $libraries['bootstrap-cdn']['js'][$js_uri] = [
        'type' => 'external',
      ];
    }
  }
  return $libraries;
}