Note: What I'm doing here is embedding controllers <--- see that link for a similar (official) example.
I want to call a controller from a twig template, and have that controller return an array that I can then use throughout the rest of my template.
I can do this with individual variables:
Twig
{% set testVar = render(controller('AppBundle:Test:index')) %}
Controller
class TestController extends Controller
{
public function testAction()
{
return new Response('OH HAI');
}
}
However, the following throws an exception: ("The Response content must be a string or object implementing __toString(), "array" given.")
with the same twig file.
public function testAction()
{
return new Response(array('test' => 1, 'foo' => 'bar'));
}
This throws the above exception. How can I accomplish that which I seek without creating a dummy, useless extra template for the controller to render?