In Symfony, context objects should be given to models via setters

I guess I knew this, but it is good to be reminded. Check out the comment by Hugo:

Retrieving a factory object (request, response, user, cache…) from the sfContext singleton is the ugly way as it relies on a string couple between classes. The ideal way to use the context in a model is to pass it explicitly with a setter like below :

Leave a Reply