Reputation: 2503
I need to store a "global" object in Symfony 1.4 system, so not a usual class into the /lib
directory. This could even be a full static, or singleton thing - but nowadays everybody say "use dependency injection!". Buy the way, this object must be exists in only one instance, not less, not more, and accessible in all controllers (not in views)
I think it should be created in the chain filter. And then?
Upvotes: 0
Views: 195
Reputation: 12322
You can either keep the object inside the sfContext or, if you want to have it a separate object, implement a static method ::getInstance()
, which will return the instance of the object or initialise it (if the instance does not exist). This way you don't even have to initialise the object in the filter chain (unless you need to pass some parameters to the constructor).
Upvotes: 1