Created
March 5, 2010 13:29
-
-
Save videlalvaro/322718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in file: AjaxController.php | |
<?php | |
/* | |
Performance wise, if you just need to return a simple text to the user | |
and you want to save resources, you may want to avoid loading the templating | |
system and return the text directly the the user | |
*/ | |
namespace Bundle\RabbitBundle\Controller; | |
use Symfony\Framework\WebBundle\Controller; | |
class AjaxController extends Controller | |
{ | |
public function renderText($content) | |
{ | |
$response = $this->container->getResponseService(); | |
$response->setContent($content); | |
return $response; | |
} | |
} | |
//in file DashboardController.php | |
<?php | |
namespace Bundle\RabbitBundle\Controller; | |
use Bundle\RabbitBundle\Controller\AjaxController; | |
use Bundle\RabbitBundle\Model\Queue; | |
class DashboardController extends AjaxController | |
{ | |
public function indexAction() | |
{ | |
return $this->renderText( | |
json_encode(array( | |
'dashboard' => array(Queue::findForVhosts()) | |
)) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment