Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Version update #2311

Merged
merged 2 commits into from

5 participants

@BinaryKitten

Updates Zend\Version\Version to enable support for classic version retrieval from framework.zend.com

BinaryKitten and others added some commits
@BinaryKitten BinaryKitten Update library/Zend/Version/Version.php
added support for different version identifier locations
ef482bf
Kathryn Reeve clean up of stray spaces 6f41798
@b-durand

Good idea :+1:

@coss

How about accepting as additional optional parameter, that excepts a Zend\Http\Client instance? That way, the developer could set the adapter which would make this method usable even if allow_url_fopen is set to off.

@weierophinney

@coss That's outside the scope of this PR; if you'd like to have that feature, please open a new request. :)

@weierophinney

Merged to release and master branches.

@weierophinney weierophinney merged commit 6f41798 into zendframework:master

1 check passed

Details default The Travis build passed
@drdev drdev commented on the diff
library/Zend/Version/Version.php
@@ -26,6 +26,16 @@
const VERSION = '2.1.0dev';
/**
+ * Github Service Identifier for version information is retreived from
+ */
+ const VERSION_SERVICE_GITHUB = 'GITHUB';
+
+ /**
+ * Github Service Identifier for version information is retreived from
@drdev
drdev added a note

Zend Service Identifier?

Since this has already been merged and done, I've created #2404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 7, 2012
  1. @BinaryKitten

    Update library/Zend/Version/Version.php

    BinaryKitten authored
    added support for different version identifier locations
  2. clean up of stray spaces

    Kathryn Reeve authored
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 12 deletions.
  1. +36 −12 library/Zend/Version/Version.php
View
48 library/Zend/Version/Version.php
@@ -26,6 +26,16 @@
const VERSION = '2.1.0dev';
/**
+ * Github Service Identifier for version information is retreived from
+ */
+ const VERSION_SERVICE_GITHUB = 'GITHUB';
+
+ /**
+ * Github Service Identifier for version information is retreived from
@drdev
drdev added a note

Zend Service Identifier?

Since this has already been merged and done, I've created #2404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ */
+ const VERSION_SERVICE_ZEND = 'ZEND';
+
+ /**
* The latest stable version Zend Framework available
*
* @var string
@@ -52,32 +62,46 @@ public static function compareVersion($version)
/**
* Fetches the version of the latest stable release.
*
- * This uses the GitHub API (v3) and only returns refs that begin with
+ * By Default, this uses the GitHub API (v3) and only returns refs that begin with
* 'tags/release-'. Because GitHub returns the refs in alphabetical order,
* we need to reduce the array to a single value, comparing the version
* numbers with version_compare().
*
+ * If $service is set to VERSION_SERVICE_ZEND this will fall back to calling the
+ * classic style of version retreival.
+ *
+ *
* @see http://developer.github.com/v3/git/refs/#get-all-references
* @link https://api.github.com/repos/zendframework/zf2/git/refs/tags/release-
+ * @link http://framework.zend.com/api/zf-version?v=2
+ * @param string $service Version Service with which to retrieve the version
* @return string
*/
- public static function getLatest()
+ public static function getLatest($service = self::VERSION_SERVICE_GITHUB)
{
if (null === self::$latestVersion) {
self::$latestVersion = 'not available';
- $url = 'https://api.github.com/repos/zendframework/zf2/git/refs/tags/release-';
+ if ($service == self::VERSION_SERVICE_GITHUB) {
+ $url = 'https://api.github.com/repos/zendframework/zf2/git/refs/tags/release-';
- $apiResponse = Json::decode(file_get_contents($url), Json::TYPE_ARRAY);
+ $apiResponse = Json::decode(file_get_contents($url), Json::TYPE_ARRAY);
- // Simplify the API response into a simple array of version numbers
- $tags = array_map(function($tag) {
- return substr($tag['ref'], 18); // Reliable because we're filtering on 'refs/tags/release-'
- }, $apiResponse);
+ // Simplify the API response into a simple array of version numbers
+ $tags = array_map(function($tag) {
+ return substr($tag['ref'], 18); // Reliable because we're filtering on 'refs/tags/release-'
+ }, $apiResponse);
- // Fetch the latest version number from the array
- self::$latestVersion = array_reduce($tags, function($a, $b) {
- return version_compare($a, $b, '>') ? $a : $b;
- });
+ // Fetch the latest version number from the array
+ self::$latestVersion = array_reduce($tags, function($a, $b) {
+ return version_compare($a, $b, '>') ? $a : $b;
+ });
+ } elseif($service == self::VERSION_SERVICE_ZEND) {
+ $handle = fopen('http://framework.zend.com/api/zf-version?v=2', 'r');
+ if (false !== $handle) {
+ self::$_latestVersion = stream_get_contents($handle);
+ fclose($handle);
+ }
+ }
}
return self::$latestVersion;
Something went wrong with that request. Please try again.