I've been going round in circles with this one. I've been either getting 500 errors saying template cannot be rendered or found, or when I attempt to use the annotations, they clash with the fact I'm using Symfony's annotations for my routes. With the current code, I'm just getting 404's.
My config:
# config.yml
fos_rest:
routing_loader:
default_format: json
An example of my controller:
namespace IGIG\GigBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use IGIG\GigBundle\Document\Gig;
class GigApiController extends FOSRestController
{
public function getGigsAction()
{
$gigs = $this->get('doctrine_mongodb')
->getRepository('IGIGGigBundle:Gig')
->findAll();
$view = $this->view($gigs, 200)
->setTemplate("IGIG:GigBundle:getGigs.html.twig")
->setTemplateVar('gigs');
return $this->handleView($view);
}
}
Routing
gigs:
prefix: /api
type: rest
resource: IGIG\GigBundle\Controller\GigApiController
I should also add, the .html.twig file within the controller doesn't actually exist, I was under the impression that it was automatically generated, is that the case?
Thanks in advance!