You are here

function charts_billboard_find_library in Charts 5.0.x

Get the location of the Billboard.js library.

Return value

string The location of the library, or FALSE if the library isn't installed.

1 call to charts_billboard_find_library()
charts_billboard_requirements in modules/charts_billboard/charts_billboard.install
Implements hook_requirements().

File

modules/charts_billboard/charts_billboard.install, line 45
Installation and uninstallation functions.

Code

function charts_billboard_find_library() {

  // The following logic is taken from libraries_get_libraries()
  $searchdir = [];

  // Similar to 'modules' and 'themes' directories inside an installation
  // profile, installation profiles may want to place libraries into a
  // 'libraries' directory.
  $searchdir[] = 'profiles/' . \Drupal::installProfile() . '/libraries';

  // Always search libraries.
  $searchdir[] = 'libraries';

  // Also search sites/<domain>/*.
  $searchdir[] = \Drupal::service('site.path') . '/libraries';
  foreach ($searchdir as $dir) {
    if (file_exists($dir . '/billboard/dist/billboard.min.js') || file_exists($dir . '/billboard/dist/billboard.js')) {
      return $dir . '/billboard';
    }
  }
  return FALSE;
}