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