You are here

function select2boxes_library_info_build in Select2 Boxes 8

Implements hook_library_info_build().

File

./select2boxes.module, line 26
Basic module file.

Code

function select2boxes_library_info_build() {

  // Prepare required config's data.
  $config = \Drupal::config('select2boxes.settings');
  $version = $config
    ->get('version');
  $url = $config
    ->get('url');
  $options = [
    'minified' => TRUE,
    'external' => TRUE,
  ];
  $libraries['select2'] = [
    'remote' => 'https://github.com/select2/select2',
    // Set a version specified in the config form.
    'version' => $version,
    'license' => [
      'name' => 'MIT',
      'url' => 'https://github.com/select2/select2/blob/master/LICENSE.md',
      'gpl-compatible' => TRUE,
    ],
    // Using CDN url and version
    // attach an appropriate external CSS and JS files.
    'css' => [
      'theme' => [
        "{$url}/{$version}/css/select2.min.css" => $options,
      ],
    ],
    'js' => [
      "{$url}/{$version}/js/select2.full.min.js" => $options,
    ],
  ];
  return $libraries;
}