开发者

Zend Framework choose controller from Plugin

Is it possible to choose controller from Pl开发者_如何学Gougin?

For example I have table of departments and categories in database. I'm fetching them and want to make certain actions(picking controller and action).

The reason - I don't want to create sepparate controller for each department and action for each category.


You may do the following:

class Content_Plugin extends Zend_Controller_Plugin_Abstract
{
  public function routeShutdown(Zend_Controller_Request_Abstract $request)
  {
    // fetching departments and categories
    // ...

    $request->setControllerName('my'); // will map class MyController
    $request->setActionName('special');  // will map MyController::specialAction();
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜