Ask your Symfony questions! Pay money and get answers fast! (more info)

How to create a factories.yml in a plugins module? Symfony


According to the reference book (sf1.4) the configuration cascade applies to the factories.yml.
<blockquote>The configuration defined in the plugins (PROJECT_ROOT_DIR/plugins/*/config/XXX.yml)

This quote implies that the file can also be located in /plugins/myPlugin/modules/myModule/config/.
However I can not get it to work..

In my case I need to configure the <strong>view_cache</strong>.

Can somebody post an example?

Answers (3)


michalg answers:


Symfony doesn't load factories configurations from /plugins/*/modules/*/config, only from /plugins/*/config

So you only can create file /plugins/myPlugin/config/factories.yml

michalg comments:

Or in your plugin configuration:

file plugins/testPlugin/config/testPluginConfiguration

class testPluginConfiguration extends sfPluginConfiguration
* @see sfPluginConfiguration
public function initialize()
sfConfig::set('sf_factory_view_cache', 'my_view_cache');
sfConfig::set('sf_factory_view_cache_parameters', array());

That way, you don't need to change application (project), just enable plugin.


Noel GUILBERT answers:


You can't do that because application config files override the plugins config files. So, you must specify the config in your application factories.yml file, and add this point on your plugin README file.


hwiens answers:

As already mentioned, there's no way to create an factories.yml especially for one module. However, you can overide the view_cache with the help of sfConfig:

sfConfig::set('sf_factory_view_cache', 'my_view_cache');

just replace <em>my_view_cache</em> with your cache class.
I suggest doing this in the configuration file of your application (or project), beacuse the ViewCache is instantiated before your action is executed.