You are here

function charts_highcharts_find_library in Charts 5.0.x

Get the location of the Highcharts library.

Return value

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

1 call to charts_highcharts_find_library()
charts_highcharts_requirements in modules/charts_highcharts/charts_highcharts.install
Implements hook_requirements().

File

modules/charts_highcharts/charts_highcharts.install, line 59
Installation and update hooks for the Charts Highcharts module.

Code

function charts_highcharts_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 . '/highcharts/highcharts.js')) {
      return $dir . '/highcharts';
    }
  }
  return FALSE;
}