You are here

function javascript_libraries_library_info_build in JavaScript Libraries Manager 8

Implements hook_library_info_build(). Used in order to declare new library and attach dependency to it.

Return value

mixed

File

./javascript_libraries.module, line 53
Toggle the inclusion of Drupal system libraries. Upload and reference custom libraries as well.

Code

function javascript_libraries_library_info_build() {
  $external_lib = \Drupal::config('javascript_libraries.settings')
    ->get('javascript_libraries_custom_libraries');
  $externals = array();
  foreach ($external_lib as $key => $lib) {
    if ($lib['scope'] == 'footer') {
      if ($lib['type'] == 'file') {
        $lib['uri'] = file_create_url($lib['uri']);
      }
      $externals[$lib['uri']] = array(
        'type' => 'external',
        'minified' => 'true',
      );
    }
  }
  $core_lib = \Drupal::config('javascript_libraries.settings')
    ->get('javascript_libraries_core_libraries');
  foreach ($core_lib as $key => $lib) {
    $dependencies[] = $lib;
  }
  $libraries['external']['dependencies'] = $dependencies;
  $libraries['external']['js'] = $externals;
  return $libraries;
}