public static function RestfulBase::parseVersionString in RESTful 7
Parses the version string.
Parameters
string $version: The string containing the version information.
string $resource_name: (optional) Name of the resource to get the latest minor version.
Return value
array Numeric array with major and minor version.
1 call to RestfulBase::parseVersionString()
- RestfulBase::getVersionFromRequest in plugins/
restful/ RestfulBase.php - Gets the major and minor version for the current request.
File
- plugins/
restful/ RestfulBase.php, line 1639 - Contains RestfulBase.
Class
- RestfulBase
- Class \RestfulBase
Code
public static function parseVersionString($version, $resource_name = NULL) {
if (preg_match('/^v\\d+(\\.\\d+)?$/', $version)) {
// Remove the leading 'v'.
$version = substr($version, 1);
}
$output = explode('.', $version);
if (count($output) == 1) {
$major_version = $output[0];
// Abort if the version is not numeric.
if (!$resource_name || !ctype_digit((string) $major_version)) {
return;
}
// Get the latest version for the resource.
return static::getResourceLastVersion($resource_name, $major_version);
}
// Abort if any of the versions is not numeric.
if (!ctype_digit((string) $output[0]) || !ctype_digit((string) $output[1])) {
return;
}
return $output;
}