1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- /*
- * This file is part of Packagist.
- *
- * (c) Jordi Boggiano <j.boggiano@seld.be>
- * Nils Adermann <naderman@naderman.de>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Packagist\WebBundle\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\Response;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- /**
- * @author Jordi Boggiano <j.boggiano@seld.be>
- */
- class ApiController extends Controller
- {
- /**
- * @Template()
- * @Route("/packages.json", name="packages")
- */
- public function packagesAction()
- {
- $version = $this->get('request')->query->get('version');
- $packages = $this->get('doctrine')
- ->getRepository('Packagist\WebBundle\Entity\Package')
- ->findAll();
- $data = array();
- foreach ($packages as $package) {
- $data[$package->getName()] = $package->toArray();
- }
- return new Response(json_encode($data), 200, array('Content-Type' => 'application/json'));
- }
- }
|