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

查看:17
本文介绍了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 中的模块不仅仅是名称空间,其中还包含一些类.因此,如果您创建一个名为 ModuleViewHelperMyHelper 的视图助手,您可以简单地在另一个模块中使用该视图助手.

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 ModuleViewHelperMyHelper, you can simply use that view helper in another module.

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

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