charts_google.install in Charts 5.0.x
Installation and uninstallation functions.
File
modules/charts_google/charts_google.installView source
<?php
/**
* @file
* Installation and uninstallation functions.
*/
/**
* Implements hook_requirements().
*/
function charts_google_requirements($phase) {
$requirements = [];
switch ($phase) {
case 'runtime':
$library_path = charts_google_find_library();
if (!$library_path) {
$requirements['charts_google_js'] = [
'title' => t('Google Charts Library'),
'value' => t('Not Installed'),
'severity' => REQUIREMENT_ERROR,
'description' => t('You are missing the Google Charts library in your Drupal installation directory. Please see the README file inside charts_google for instructions to install the library.'),
];
}
else {
$requirements['charts_google_js'] = [
'title' => t('Google Charts Library'),
'severity' => REQUIREMENT_OK,
'value' => t('Installed'),
];
}
break;
}
return $requirements;
}
/**
* Get the location of the Google Charts library.
*
* @return string
* The location of the library, or FALSE if the library isn't installed.
*/
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;
}
Functions
Name | Description |
---|---|
charts_google_find_library | Get the location of the Google Charts library. |
charts_google_requirements | Implements hook_requirements(). |