开发者

How to call Action Helper as broker method in View Helper?

I have Action Helper that is database abstraction layer.

I would like to access it in View Helper to read and present some data from the model.

I开发者_如何学Cn Controller I call Action Helper as broker method, but how to achieve the same in View Helper?

Somewhere in controller:

$this->_helper->Service("Custom\\PageService");

Service.php:

...
public function direct($serviceClass)
{
    return new $serviceClass($this->em);
}


Nicer way will be to create a view helper inside it do

  Zend_Controller_Action_HelperBroker::getStaticHelper('service')->direct("Custom\\PageService");

another way would be inside controller init method do

$this->view->helper = $this->_helper;

so in view (phtml) you can do

$this->helper->Service("Custom\\PageService");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜