[symfony-users] Re: Symfony2 returning a JSON object

2011-06-15 Thread alex.pilon
It would be nice to emulate similar functionality to rails in which you can "respond_with" a collection or an object and the action will detect what Content-Type it should respond with. On May 12, 8:13 am, Christophe COEVOET wrote: > Le 12/05/2011 14:04, Javier Garcia a crit : > > > On May 12, 1:

Re: [symfony-users] Re: Symfony2 returning a JSON object

2011-05-12 Thread Christophe COEVOET
Le 12/05/2011 14:04, Javier Garcia a écrit : On May 12, 1:51 pm, Christophe COEVOET wrote: the render method is not about creating a response. It is about creating a response *with a content set by a template*. Yes, but.. why not implement render() to create responses whose *content could be

[symfony-users] Re: Symfony2 returning a JSON object

2011-05-12 Thread Javier Garcia
On May 12, 1:51 pm, Christophe COEVOET wrote: > the render method is not about creating a response. It is about creating > a response *with a content set by a template*. Yes, but.. why not implement render() to create responses whose *content could be 'anything' (JSON data for example, you kno

Re: [symfony-users] Re: Symfony2 returning a JSON object

2011-05-12 Thread Christophe COEVOET
Le 12/05/2011 13:34, Javier Garcia a écrit : Since for rendering templates you have to use this: return $this->render('FooBarBundle:Default:index.html.twig'); wouldn't be more "natural" implementing something like: $this->render(json_encode($data), 'json'); ??? The second argument would set th

[symfony-users] Re: Symfony2 returning a JSON object

2011-05-12 Thread Javier Garcia
> > On Apr 26, 8:11 am, Fabien Potencier > project.com> wrote: > > >> return new Response(json_encode($data)); > > >> Fabien Since for rendering templates you have to use this: return $this->render('FooBarBundle:Default:index.html.twig'); wouldn't be more "natural" implementing something like:

Re: [symfony-users] Re: Symfony2 returning a JSON object

2011-04-26 Thread Tim Nagel
There is no response object 'on the go'. The controller action's responsibility is to create the response. t On Wed, Apr 27, 2011 at 07:59, stickaforkinme wrote: > Yeah worked that one out after posting on here... although prefered > the old renderText method of sfActions in sf 1.x as this was

[symfony-users] Re: Symfony2 returning a JSON object

2011-04-26 Thread stickaforkinme
Yeah worked that one out after posting on here... although prefered the old renderText method of sfActions in sf 1.x as this was a bit cleaner. :-) Creating a new response object just seems an odd way to do it as surly you already have a response object on the go. On Apr 26, 8:11 am, Fabien Potenc