Now THAT is awesome :) -- Ian
----- Original Message ----- From: "Fabien POTENCIER" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, June 27, 2007 12:20 PM Subject: [symfony-devs] About singletons > > Hi all, > > As I currently do some major changes, I want to give you some more > information on what's going on in the trunk. > > One of main "problem" with the current symfony 1.0 design is the use of > a lot of singleton objects and static classes/methods. It limits the > ability to override those classes or to change the behavior of certain > parts of the framework (sfRouting, sfI18N, sfContext for example). > > I started some refactoring to remove some singletons and to try to ease > extending the base framework classes. The ultimate goal is to be able to > deal with several symfony applications in the same PHP script. It will > allow great things like the ability to create a link between symfony > applications (I think this is the most FAQ on symfony). So, I want to be > able to write something like this in the future in a backend application: > > $frontend = sfContext::getInstance('frontend'); > $url = $frontend->getRouting()->generate(...); > > Or if you have to switch to another application temporarily: > > sfContext::switch('frontend'); > > // Now sfContext::getInstance() returns the frontend sfContext object > > sfContext::switchTo('backend'); > > So, here is a summary of the things I changed in the trunk: > > - sfI18N is not a singleton anymore. This one is was really simple. The > sfI18N wasn't really used as a singleton! The i18n object is now > configurable in your factories.yml. No change is needed to your code. > > - sfRouting is not a singleton anymore. This is one was a bit more > challenging but most of the time, you don't have to change your code. > The only thing to check is if you use sfRouting::getInstance() in your > code, you will have to change it to > sfContext::getIntance()->getRouting(). The routing class is also > configurable in the factories.yml and I implemented a simple sfNoRouting > class as an example of a very simple routing class. > > - sfContext is now a multi-singleton. The getInstance() takes a name > parameter and I implemented the switchTo() method. To be really useful, > more work is needed (I need to de-singleton-ize sfConfig for example). > > - You can now store your own object in the context instance: > > $context = sfContext::getInstance(); > $context->setObject('name', $myObject); > $object = $context->getObject('name'); > > Fabien > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en -~----------~----~----~----~------~----~------~--~---
