doucuo8618 2010-07-29 13:18
浏览 34

在Zend-Framework插件中,如何做类似于$ this-> view-> foo = ...;?

i wrote a small plugin, so i will be able to get the name of the controller in each view. but idk how to "pass" a parameter to the view (do sumth like $this->view->foo =...;).

class Zend_Extension_Controller_Plugin_GetControllerName extends Zend_Controller_Plugin_Abstract
{

    public function __construct()
    {

    }

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $this->view->controllerName = $request->getControllerName();
    }
}

what can i write instead of $this->view->controllerName so it will work?

  • 写回答

3条回答 默认 最新

  • douyueqing1530 2010-07-29 13:26
    关注

    You can use the helper broker to get an instance of the view. Something like this should work:

    Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view->foo = 'bar';
    
    评论

报告相同问题?