简体   繁体   中英

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. 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

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.

  1. [production]
  2. news.resources.db.adapter = "pdo_mysql"
  3. news.resources.db.params.host = "localhost"
  4. news.resources.db.params.username = "webuser"
  5. news.resources.db.params.password = "XXXXXXX"
  6. news.resources.db.params.dbname = "news"

I was missing a module Bootstrap file.

Added /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.

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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