Active
Project:
Libraries API
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 Jan 2017 at 15:42 UTC
Updated:
2 Jan 2017 at 15:42 UTC
Jump to comment: Most recent
Reading about "versions" in libraries/libraries.api.php:
Each value is an associative array of top-level properties that are entirely overridden by the version.
However, this isn't the case when detecting libraries - only the top level "version arguments" are used.
The work-around is to create a version callback function that first check top level "version arguments" and then all the versions "version arguments":
function mymodule_libraries_get_version($library, $options) {
// Detect the version using library defaults.
$version = libraries_get_version($library, $options);
if (!empty($version)) {
return $version;
}
// Sort versions in descending order (newest first).
krsort($library['versions']);
// Detect the version using version specific overrides.
foreach ($library['versions'] as $version_properties) {
if (isset($version_properties['version arguments'])) {
$options = $version_properties['version arguments'] += $options;
$version = libraries_get_version($library, $options);
if (!empty($version)) {
return $version;
}
}
}
}
Anyway, if there is a new 2.x release please document this better.
Comments