function responsive_menu_get_library_version in Responsive and off-canvas menu 8.3
Same name and namespace in other branches
- 8.2 responsive_menu.install \responsive_menu_get_library_version()
- 4.4.x responsive_menu.install \responsive_menu_get_library_version()
- 4.0.x responsive_menu.install \responsive_menu_get_library_version()
- 4.1.x responsive_menu.install \responsive_menu_get_library_version()
- 4.3.x responsive_menu.install \responsive_menu_get_library_version()
Returns a version string.
Parameters
string $version_path: The path to the file containing the version.
Return value
string A version string or '0' if not found.
1 call to responsive_menu_get_library_version()
- responsive_menu_requirements in ./
responsive_menu.install - Implements hook_requirements().
File
- ./
responsive_menu.install, line 176 - Contains install and update functions.
Code
function responsive_menu_get_library_version($version_path) {
if (!file_exists(DRUPAL_ROOT . $version_path)) {
return '0';
}
// The hammerjs library does not contain the version number in the
// bower.json file.
if (strpos($version_path, '.json') === FALSE) {
preg_match('/\\sv(.+?)\\s/', file_get_contents(DRUPAL_ROOT . $version_path), $matches);
return isset($matches[1]) ? $matches[1] : '0';
}
// Otherwise load the bower.json file and process.
$json = file_get_contents(DRUPAL_ROOT . $version_path);
if (!$json) {
return '0';
}
$bower_array = json_decode($json, TRUE);
if (isset($bower_array['version'])) {
return $bower_array['version'];
}
return '0';
}