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();
}
}
精彩评论