简体   繁体   English

Zend Framework-从注册的插件中获取帮助器

[英]Zend Framework - Getting a helper from within a registered plugin

Is there any way to get access to a helper class from within a registered plugin. 有什么方法可以从注册的插件中访问帮助程序类。 From within the controller, one can use: 在控制器内部,可以使用:

$this->_helper->getHelper($helperName);

Specifically, we use the FlashMessenger helper to pass error and info messages around to different pages before we do a redirect. 具体来说,在执行重定向之前,我们使用FlashMessenger帮助器将错误和信息消息传递到不同的页面。 In one of our plugins, we log a user out and set the index and controller to a different page. 在我们的一个插件中,我们将用户注销,然后将索引和控制器设置到其他页面。 We could manually set a value in the request but this seems to go against what the FlashMessenger is supposed to be used for and we'd have to do that just for this special case. 我们可以在请求中手动设置一个值,但这似乎与FlashMessenger应该使用的值背道而驰,我们仅在特殊情况下必须这样做。

You should use the action helper broker to retrieve a helper anywhere outside a controller. 您应该使用操作帮助程序代理来检索控制器外部任何地方的帮助程序。 See the similar question: 看到类似的问题:

zend-framework, call an action helper from within another action helper zend-framework,从另一个动作助手中调用动作助手

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM