summaryrefslogtreecommitdiffstats
path: root/provision.inc
diff options
context:
space:
mode:
authorAntoine Beaupré2011-04-05 18:20:08 (GMT)
committerAntoine Beaupré2011-04-05 18:42:17 (GMT)
commit7f4700b979c0c6749d8c4ed56ff31f820330ca22 (patch)
tree09c08f2ba9ffd145ef64c983466ea78b01b22846 /provision.inc
parent59c2e2ae4604bd97f7194f834518336b4bf7d19c (diff)
add provision_api_version() function to return the major version of
this release
Diffstat (limited to 'provision.inc')
-rw-r--r--provision.inc40
1 files changed, 39 insertions, 1 deletions
diff --git a/provision.inc b/provision.inc
index 0f3b3fe..7aed963 100644
--- a/provision.inc
+++ b/provision.inc
@@ -321,7 +321,14 @@ function provision_backend_invoke($target, $command, $arguments = array(), $data
}
/**
- * parse the .ini file to get the aegir version
+ * the aegir version of the backend
+ *
+ * @return string
+ * the aegir version as stored in the .info file, potentially
+ * including the 6.x- prefix. to get a cleaned up version, use
+ * provision_version_parts()
+ *
+ * @see provision_version_parts()
*/
function provision_version() {
$ini = parse_ini_file(dirname(__FILE__) . '/provision.info');
@@ -329,6 +336,37 @@ function provision_version() {
}
/**
+ * Aegir API implemented by this backend
+ *
+ * This is the major release number, the first part of the version
+ * stored in the info file
+ *
+ * @return int
+ * a number greater than zero, 1 for 1.0 or 1.0-rc2, 2 for 2.0, etc.
+ *
+ * @see provision_version_parts()
+ */
+function provision_api_version() {
+ $parts = provision_version_parts();
+ return $parts[0];
+}
+
+/**
+ * The different parts of the version number
+ *
+ * This cleans up the version number by removing the Drupal version
+ * (6.x-...) and splits the remaining version on dots.
+ *
+ * @return array
+ * the major and minor version numbers, e.g. array(1, 0-rc3) for
+ * 1.0-rc3 or array(1, 2) for 1.2
+ */
+function provision_version_parts() {
+ $version = preg_replace('/^[^-]*-/', '', provision_version()); // remove "6.x-"
+ return explode('.', $version);
+}
+
+/**
* A base class for the service and file handling classes that implements
* chaining of methods.
*/