You are here

function charts_google_find_library in Charts 5.0.x

Get the location of the Google Charts library.

Return value

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

1 call to charts_google_find_library()
charts_google_requirements in modules/charts_google/charts_google.install
Implements hook_requirements().

File

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

Code

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