You are here

function _pdb_library_build_js in Decoupled Blocks 8

Helper function to process and build library js assets.

1 call to _pdb_library_build_js()
pdb_library_info_build in ./pdb.module
Implements hook_library_info_build().

File

./pdb.module, line 112
PDB Module.

Code

function _pdb_library_build_js($info, $path) {
  $js_assets = [];
  if (isset($info['add_js']['header'])) {

    // Supports current simplest method to add js assets to the library.
    if (!isset($info['add_js']['header']['js'])) {

      // This assumes add_js -> header contains the assets.
      $info['add_js']['header'] = [
        'js' => $info['add_js']['header'],
      ];
    }
    $header_js = _pdb_library_build_get_assets($info['add_js']['header']['js'], $path);
    $info['add_js']['header']['js'] = $header_js;
    $js_assets['header'] = $info['add_js']['header'];
  }
  if (!empty($info['add_js']['footer'])) {
    if (!isset($info['add_js']['footer']['js'])) {

      // This assumes add_js -> footer contains the assets.
      $info['add_js']['footer'] = [
        'js' => $info['add_js']['footer'],
      ];
    }
    $footer_js = _pdb_library_build_get_assets($info['add_js']['footer']['js'], $path);
    $info['add_js']['footer']['js'] = $footer_js;
    $js_assets['footer'] = $info['add_js']['footer'];
  }
  return $js_assets;
}