Browse Source

Add a packages/list route which allows listing all package names

Nils Adermann 13 years ago
parent
commit
9ca7558846
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/Packagist/WebBundle/Controller/WebController.php

+ 13 - 0
src/Packagist/WebBundle/Controller/WebController.php

@@ -76,6 +76,19 @@ class WebController extends Controller
         return $data;
     }
 
+    /**
+     * @Route("/packages/list.json", name="list", defaults={"_format"="json"})
+     * @Method({"GET"})
+     */
+    public function listAction(Request $req)
+    {
+        $packageNames = $this->getDoctrine()
+            ->getRepository('PackagistWebBundle:Package')
+            ->getPackageNames();
+
+        return new Response(json_encode(array('packageNames' => $packageNames)), 200);
+    }
+
     /**
      * Initializes the pager for a query.
      *