开发者

Zend Framework choose controller from Plugin

开发者 https://www.devze.com 2023-01-08 09:26 出处:网络
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 control

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

精彩评论

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

关注公众号