简体   繁体   English

application.ini 中的模块特定资源配置

[英]Module specific resource configuration in application.ini

Can I config a resource to be different when a specific module is used?使用特定模块时,我可以将资源配置为不同吗?

From what I have read in the documentation (example #12) this should be possible.根据我在文档中阅读的内容(示例#12) ,这应该是可能的。 But I have had no luck with it yet.但我还没有运气。

In detail, I'm trying to set another path for translation files.详细地说,我正在尝试为翻译文件设置另一个路径。

resources.translate.adapter = "array"
resources.translate.data = APPLICATION_PATH "/views/languages"
resources.translate.options.scan = "filename"
resources.translate.options.disableNotices = true
resources.translate.options.logUntranslated = false 
mobile.resources.translate.data = APPLICATION_PATH "/modules/mobile/views/languages"

From the docs从文档

Example #12 Configuring Modules Example #12 配置模块

You can specify module-specific configuration using the module name as a prefix or sub->section in your configuration file.您可以使用模块名称作为配置文件中的前缀或子部分来指定特定于模块的配置。

For example, let's assume that your application has a "news" module.例如,假设您的应用程序有一个“新闻”模块。 The following are INI >and XML examples showing configuration of resources in that module.以下是 INI > 和 XML 示例,显示了该模块中的资源配置。

  1. [production] [生产]
  2. news.resources.db.adapter = "pdo_mysql" news.resources.db.adapter = "pdo_mysql"
  3. news.resources.db.params.host = "localhost" news.resources.db.params.host = "本地主机"
  4. news.resources.db.params.username = "webuser" news.resources.db.params.username = "网络用户"
  5. news.resources.db.params.password = "XXXXXXX" news.resources.db.params.password = "XXXXXXX"
  6. news.resources.db.params.dbname = "news" news.resources.db.params.dbname = "新闻"

I was missing a module Bootstrap file.我缺少一个模块引导文件。

Added /modules/mobile/Bootstrap.php添加 /modules/mobile/Bootstrap.php

<?php

class Mobile_Bootstrap extends Zend_Application_Module_Bootstrap {
}

Now things work, and the per module translation also (mentioned in comments on initial post).现在一切正常, 每个模块的翻译也可以(在初始帖子的评论中提到)。

I think you forgot to initialize your modules, as you do not boostrap them.我认为您忘记初始化模块,因为您没有引导它们。

From the documentation (where you are pointing )从文档(您指向的地方)

Since the Modules resource does not take any arguments by default, in order to enable it via configuration, you need to create it as an empty array.由于 Modules 资源默认不占用任何 arguments,为了通过配置启用它,您需要将其创建为空数组。

So you need to create the module array through your configuration files, and for example for your modules you can populate it with:因此,您需要通过配置文件创建模块数组,例如,对于您的模块,您可以使用以下内容填充它:

resources.modules[] = "default"
resources.modules[] = "mobile"

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

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