php - MVC calling another controller's action from another controller's action -
let's imagine have ordercontroller
controller 3 actions/pages: orderdetailsaction
, orderhistoryaction
, ordercustomerdetailsaction
each of these actions returning piece of html.
now want have page containing 3 html pieces in same time, but don't want make 3 ajax calls done.
i'm creating additional controller's action method (ordersummaryaction
, example). method should contain 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 framework doing such things or maybe bad practice (what better practice then)?
thank you!
upd: or can pass not string url, route create new application instance. better, imho.
symfony2 uses sub-request invoke multiple controllers. can find more details under 'embedding controllers' here http://symfony.com/doc/current/book/templating.html
Comments
Post a Comment