瀏覽代碼

Added getAllComposerFiles method.

xaav 13 年之前
父節點
當前提交
0091b53f76

+ 19 - 0
src/Packagist/WebBundle/Repository/Repository/GitRepository.php

@@ -14,6 +14,9 @@ class GitRepository implements RepositoryInterface
         $this->repository = $match[2];
     }
 
+    /**
+     * @deprecated
+     */
     public function getComposerFile($hash)
     {
         return json_decode(file_get_contents('https://raw.github.com/'.$this->owner.'/'.$this->repository.'/'.$hash.'/composer.json'), true);
@@ -24,6 +27,9 @@ class GitRepository implements RepositoryInterface
         return json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository), true);
     }
 
+    /**
+     * @deprecated
+     */
     public function getTagsData()
     {
         return json_decode(file_get_contents('http://github.com/api/v2/json/repos/show/'.$this->owner.'/'.$this->repository.'/tags'), true);
@@ -43,4 +49,17 @@ class GitRepository implements RepositoryInterface
     {
         return $this->repository;
     }
+
+
+    public function getAllComposerFiles()
+    {
+        $files = array();
+
+        $tagsData = $this->getTagsData();
+        foreach ($tagsData['tags'] as $tag => $hash) {
+            $files[] = $this->getComposerFile($hash);
+        }
+
+        return $files;
+    }
 }

+ 2 - 2
src/Packagist/WebBundle/Repository/Repository/RepositoryInterface.php

@@ -5,7 +5,7 @@ namespace Packagist\WebBundle\Repository\Repository;
 interface RepositoryInterface
 {
     /**
-     * Returns the decoded composer.json file.
+     * Return an array of all composer files (by tag).
      */
-    public function getComposerFile($hash);
+    public function getAllComposerFiles();
 }