.info 中的 files[] 的用途是什么?
我刚刚开始学习发现 Drupal 7 的更改,并且我刚刚发现 mymodule.info
中现在需要 files[]
数组。根据我的发现,需要将 mymodule.module 文件添加到列表中,但它还有什么其他用途?
根据我读到的内容,我认为我应该能够将我的代码分成几个文件,例如我想创建一个 mymodule.blocks.inc
来包含我的块的所有代码,但它似乎 mymodule_block_info() 函数永远不会运行。
我做错了什么,还是这不是它应该使用的方式?
I've just started learning discovering the changes to Drupal 7, and I just found the files[]
array now required in the mymodule.info
. From what I've found, it is required to add the mymodule.module
file to the list, but what other uses does it have?
From what I've read I figured I should be able to separate my code into several files, for example I wanted to make a mymodule.blocks.inc
to contain all the code for my blocks, but it seems like the mymodule_block_info()
function never runs.
Am I doing something wrong, or is this not how it is supposed to be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如文档所述:
仅当您在
files[]
中指定的文件包含类或接口时才使用此选项。如果是这样,该文件将仅在需要时自动加载。不应使用
files[]
声明其他文件。As the documentation says:
This is only used if the file you specify in
files[]
contains a class or an interface. If so, the file will be auto-loaded only when needed.No other files should be declared using
files[]
.最初是为每个模块制作一个文件注册表,但现在不再使用,而是Drupal自己做。
如果您想将模块分成多个文件,则应将它们包含在 .module 文件的顶部。
At the beginning it was to make a files registry for each module, but it's not longer used as Drupal do it by himself.
If you want separate your module in multiple files, you should include them in the top of your .module file.
在我看来,指定为
files[]
的文件意味着支持文件并在需要时调用。应在.module
文件或$module.$group.inc
文件中指定已实现的默认 Drupal 挂钩,以便 Drupal 识别它们。请参阅hook_hook_info()。另请参阅 http://drupal.org/node 的文件下的文档中的注释/542202。
The way I see it, files specified as
files[]
are meant to be supporting files and called upon when needed. Implemented default Drupal hooks should be specified in the.module
file or in the$module.$group.inc
file in order for Drupal to recognize them. See hook_hook_info().Also, see the note in the documentation under files at http://drupal.org/node/542202.