Procházet zdrojové kódy

Move code to the right place, refs #694

Jordi Boggiano před 8 roky
rodič
revize
4a56467063

+ 2 - 14
src/Packagist/WebBundle/Controller/PackageController.php

@@ -323,27 +323,15 @@ class PackageController extends Controller
 
         if ('json' === $req->getRequestFormat()) {
             $data = $package->toArray($this->getDoctrine()->getRepository('PackagistWebBundle:Version'));
+            $data['dependents'] = $repo->getDependentCount($package->getName());
+            $data['suggesters'] = $repo->getSuggestCount($package->getName());
 
             try {
                 $data['downloads'] = $this->get('packagist.download_manager')->getDownloads($package);
                 $data['favers'] = $this->get('packagist.favorite_manager')->getFaverCount($package);
-                $data['dependents'] = $repo->getDependentCount($package->getName());
-                $data['suggesters'] = $repo->getSuggestCount($package->getName());
-                $data['github_stars'] = $package->getGitHubStars();
-                $data['github_watchers'] = $package->getGitHubWatches();
-                $data['github_forks'] = $package->getGitHubForks();
-                $data['github_open_issues'] = $package->getGitHubOpenIssues();
-                $data['language'] = $package->getLanguage();
             } catch (ConnectionException $e) {
                 $data['downloads'] = null;
                 $data['favers'] = null;
-                $data['dependents'] = null;
-                $data['suggesters'] = null;
-                $data['github_stars'] = null;
-                $data['github_watchers'] = null;
-                $data['github_forks'] = null;
-                $data['github_open_issues'] = null;
-                $data['language'] = null;
             }
 
             // TODO invalidate cache on update and make the ttl longer

+ 5 - 0
src/Packagist/WebBundle/Entity/Package.php

@@ -203,6 +203,11 @@ class Package
             'versions' => $versions,
             'type' => $this->getType(),
             'repository' => $this->getRepository(),
+            'github_stars' => $package->getGitHubStars(),
+            'github_watchers' => $package->getGitHubWatches(),
+            'github_forks' => $package->getGitHubForks(),
+            'github_open_issues' => $package->getGitHubOpenIssues(),
+            'language' => $package->getLanguage(),
         );
 
         if ($this->isAbandoned()) {