Zend Framework 2自定义视图助手-跨模块 [英] Zend Framework 2 custom view helpers - cross modules

查看:69
本文介绍了Zend Framework 2自定义视图助手-跨模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Zend Framework 2中,如何为多个模块提供一个视图助手?

In Zend Framework 2, how can I have one view helper available to multiple modules?

我想要的是具有一些通用功能,例如算法功能,可以被多个模块重用.

What I want is to have some general functions, like algorithmic functions, that can be reused by multiple modules.

我目前正在使用ZF 2 2.0.3

I'm currently on ZF 2 2.0.3

谢谢.

推荐答案

很简单,将其放在您的模块之一中.您可以使用ZF2中其他模块中的类和函数.因为ZF2中的模块不只是名称空间,而且还包含一些类.因此,如果您创建名称为\Module\View\Helper\MyHelper的视图助手,则只需在另一个模块中使用该视图助手即可.

Its simple, put it in one of your modules. You can use classes and functions from other modules in ZF2. Because modules in ZF2 aren't much more than just namespaces, with some classes in them. So, if you create a view helper with the name \Module\View\Helper\MyHelper, you can simply use that view helper in another module.

这篇关于Zend Framework 2自定义视图助手-跨模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆