public static function RestfulBase::getResourceLastVersion in RESTful 7
Return the last version for a given resource.
Parameters
string $resource_name: The name of the resource.
int $major_version: Get the last version for this major version. If NULL the last major version for the resource will be used.
Return value
array Array containing the major_version and minor_version.
4 calls to RestfulBase::getResourceLastVersion()
- RestfulBase::getVersionFromRequest in plugins/
restful/ RestfulBase.php - Gets the major and minor version for the current request.
- RestfulBase::parseVersionString in plugins/
restful/ RestfulBase.php - Parses the version string.
- RestfulCToolsPluginsDiscovery::getPlugins in plugins/
restful/ ctools_plugins/ 1.0/ RestfulCToolsPluginsDiscovery.class.php - Overrides \RestfulDataProviderCToolsPlugins::getPlugins().
- RestfulEntityBase::addDefaultValuesToPublicFields in plugins/
restful/ RestfulEntityBase.php - Add default values to the public fields array.
File
- plugins/
restful/ RestfulBase.php, line 1472 - Contains RestfulBase.
Class
- RestfulBase
- Class \RestfulBase
Code
public static function getResourceLastVersion($resource_name, $major_version = NULL) {
$resources = array();
// Get all the resources corresponding to the resource name.
foreach (restful_get_restful_plugins() as $resource) {
if ($resource['resource'] != $resource_name || isset($major_version) && $resource['major_version'] != $major_version) {
continue;
}
$resources[$resource['major_version']][$resource['minor_version']] = $resource;
}
// Sort based on the major version.
ksort($resources, SORT_NUMERIC);
// Get a list of resources for the latest major version.
$resources = end($resources);
if (empty($resources)) {
return;
}
// Sort based on the minor version.
ksort($resources, SORT_NUMERIC);
// Get the latest resource for the minor version.
$resource = end($resources);
return array(
$resource['major_version'],
$resource['minor_version'],
);
}