Let’s imagine that we have OrderController controller with three actions/pages: orderDetailsAction, orderHistoryAction, orderCustomerDetailsAction
Each of these actions are returning some piece of HTML.
Now I want to have page containing all 3 html pieces in same time, but I don’t want to make 3 ajax calls to get this done.
I’m creating additional controller’s action method (orderSummaryAction, for example). This method should contain something like this.
public function orderSummartyAction {
ob_start();
Application::factory()->run('/order/details');
Application::factory()->run('/order/history');
Application::factory()->run('/order/customer_details');
$out = ob_get_clean();
$this->getResponse()->setHtml($out);
}
Is there any framework doing such things or maybe it is bad practice (what is better practice then)?
Thank you!
UPD: Or we can pass not string url, but Route to create new Application instance. It would be much better, imho.
Symfony2 uses sub-request to invoke multiple controllers.
You can find more details under ‘Embedding Controllers’ here http://symfony.com/doc/current/book/templating.html