From 5cef486981d66873a302c40ec1bf3b94ed3f619b Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Thu, 25 Sep 2014 18:33:47 -0700 Subject: [PATCH] Added Upgrader GPM class which allows to get details about the latest version of Grav available including version, release date and available assets to download --- system/src/Grav/Common/GPM/Upgrader.php | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 system/src/Grav/Common/GPM/Upgrader.php diff --git a/system/src/Grav/Common/GPM/Upgrader.php b/system/src/Grav/Common/GPM/Upgrader.php new file mode 100644 index 000000000..312e77bb2 --- /dev/null +++ b/system/src/Grav/Common/GPM/Upgrader.php @@ -0,0 +1,75 @@ +remote = new Remote\Grav($refresh, $callback); + } + + /** + * Returns the release date of the latest version of Grav + * @return string + */ + public function getReleaseDate() + { + return $this->remote->getDate(); + } + + /** + * Returns the version of the installed Grav + * @return string + */ + public function getLocalVersion() + { + return GRAV_VERSION; + } + + /** + * Returns the version of the remotely available Grav + * @return string + */ + public function getRemoteVersion() + { + return $this->remote->getVersion(); + } + + /** + * Returns an array of assets available to download remotely + * @return array + */ + public function getAssets() + { + return $this->remote->getAssets(); + } + + /** + * Checks if the currently installed Grav is upgradable to a newer version + * @return boolean True if it's upgradable, False otherwise. + */ + public function isUpgradable() + { + return version_compare($this->getLocalVersion(), $this->getRemoteVersion(), "<"); + } +}