xaav 14 жил өмнө
parent
commit
316b2b009d

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

@@ -114,6 +114,34 @@ class WebController extends Controller
         return new Response(json_encode($response));
     }
 
+    /**
+     * View all packages with the specified tag.
+     *
+     * @Template("PackagistWebBundle:Web:index.html.twig")
+     * @Route("/tag/{name}", name="tag")
+     */
+    public function tagAction($name)
+    {
+        $tag = $this->getDoctrine()
+            ->getRepository('PackagistWebBundle:Tag')
+            ->findOneByName($name);
+        if (empty($tag)) {
+            throw new NotFoundHttpException();
+        }
+
+        $versions = $tag->getVersions();
+
+        if (empty($versions)) {
+            throw new NotFoundHttpException();
+        }
+
+        foreach($versions as $version) {
+            $packages[] = $version->getPackage();
+        }
+
+        return array('packages' => $packages, 'page' => 'home');
+    }
+
     /**
      * @Template()
      * @Route("/about", name="about")