I'm using Symfony2 , I'm still getting familiar with this framework. And while using my control I'm not sure how to get the output generated by it and play to a string. I need to play to a string to handle, as I'm using pjax and if the request is a request originating from pjax I need to send only a snippet of the page (the content I want to modify), to do this I plan to use the Crawler and then return only the correct content, depending on the situation. The problem is that I do not know how to do how to capture the HTML that the Controller generates.
<?php
/**
* State controller.
*
* @Route("/state")
*/
class StateController extends Controller {
/**
* Lists all State entities.
*
* @Route("/", name="state")
* @Method("GET")
* @Template()
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('AmbulatoryBundle:State')->findAll();
$rendered = $this->render('TestBundle:State:index.html.twig', array(
'entities' => $entities,
));
return $rendered; // Preciso pegar o conteúdo gerado aqui em string
}
? >