You are here

function charts_c3_find_library in Charts 5.0.x

Get the location of the C3.js library.

Return value

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

1 call to charts_c3_find_library()
charts_c3_requirements in modules/charts_c3/charts_c3.install
Implements hook_requirements().

File

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

Code

function charts_c3_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 . '/c3/c3.min.js') || file_exists($dir . '/c3/c3.js')) {
      return $dir . '/c3';
    }
  }
  return FALSE;
}