0

if I want to automatically read a custom yml file i can use the following statement in apps/myapp/config/myappConfiguration.class.php (sfApplicationConfiguration subclass).

require_once($this->getConfigCache()->checkConfig('config/mycustom.yml'));

However, I want the data to be available to the entire project. The equivalent file in config/ is a sfProjectConfiguration subclass which doesn't have the getConfigCache() method. What am i missing?

greg0ire
  • 22,714
  • 16
  • 72
  • 101
Mark Hamlin
  • 339
  • 1
  • 10
  • Not an issue anymore as other requirements forced us to use a bespoke solution (based on existing components) to parse and transform the yml at runtime. – Mark Hamlin Apr 19 '11 at 12:39

2 Answers2

0

This is one more reason (among others such as code reuse, i18n and testing) to have only one application in your project.

Dziamid
  • 11,225
  • 12
  • 69
  • 104
  • Uh? Does all would be reason to have more than one application in your project? If you have multiple projects than you would have to duplicate your code, rather than load a plugin. Same for testing: if you have two 'coupled' projects, you would have to test two projects instead of 1. Or update translations in two projects instead of one plugin? Or update rather one setting in the `custom.yml` thann in the `custom.yml`'s of two projects? – Grad van Horck Apr 19 '11 at 06:58
  • For more than one app, reusable components can be put into one or more plugins. – cmc Aug 24 '12 at 15:17
0

You are correct: you can only read settings on an application level. But the configuration 'stack' always checks 'all locations' before parsing. So if you read your custom.yml in the application configuration, it automatically adds the custom.yml in the /config. So you can add the config_handler just like you would, and only define the custom.yml on project level (in /config) and not on application (/config) level.

Grad van Horck
  • 4,488
  • 1
  • 21
  • 22
  • So am I right in thinking this that in this scenario the only duplication required is the "require_once($this->getConfigCache()->checkConfig..." statement in all appropriate apps/myapp*/myapp*Configuration.class.php files? – Mark Hamlin Apr 19 '11 at 12:35
  • Yes, but you create a new baseclass for your application configuration classes (which would extend `sfApplicationConfiguration`). Or, you could write your own class, which encapsulate your settings, just like `sfConfig` does. That way you can make sure the configuration is only loaded when needed. – Grad van Horck Apr 19 '11 at 14:03