Cheers folks,
Agavi's Model implementation currently lacks support for Singletons. From
what I can see, there are three ways to implement that:
1) if you want your Model to be Singleton, extend SingletonModel instead of
Model. The Controller will automagically call getInstance() when he stumbles
over a class that is a singleton. This method is guaranteed to work, as I
already implemented it
2) have a separate method, Comtroller::get(Global)SingletonModel(). IMO,
this sucks big time
3) change Controller::get(Global)Model() to accept a third parameter which
defines the method that will be used to fetch an instance (i.e. $singleton =
Controller::getGlobalModel('whatever', 'getInstance);). This obviously
sucks, too, as we'll be running into trouble when we add more parameters to
those methods (for example when passing parameters, this is currently in
discussion IIRC).
4) do #3, but use an array as the only parameter instead: $singleton =
Controller::getModel('blahmodule', array('ModelName', 'getInstance')); -
sucks as well if you ask me
I opt for method #1. Will create a branch soon where this is implemented,
but I wanted to chime in and ask for opinions before I go ahead and start
working. So... objections, anyone?
- David
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev