To me this is addressing a different issue, I think that you could have the Singleton Model so when the model is designed it can extend Singleton Model rather than Model.

But I like this approach of instantiating the model. However I see a problem with the $args and $means argument, which I think we need to address. This goes back to the separation of constructor and initialiser methods. The fourth methods tells how we are to create the object, whilst the third tells what the new object should be initialised to. Will this separation be enforced? That is will the $args be passed to the initialize() method?

graeme.


Mike Vincent wrote:
On 7/21/05, David Zülke <[EMAIL PROTECTED]> wrote:
  
I still think there should be the possibility to have Models that implement
the Singleton pattern. I came up with another idea on how to implement it
today:

Controller:get(Global)Model() could optionally accept an array as the second
(first) argument. This array would contain two items: the model name, as
usual, and, as the second parameter, the method name the Controller should
use to retrieve an instance. So when I do

$this->getContext()->getController()->getModel('Default',
array('Navigation', 'getInstance'));
    

I do like this approach better. It sort of conflicts with another
itch, but we can possibly iron out both itches in one shot. The other
itch is not being able to pass parameters into models that have
functional constructors.  Would you be ok with the optional singleton
parameter being 4th in the method signature?

Controller::getModel($module, $model, $args=null, $means=null)

$means for lack of a better word, would be the 'getInstance' call
$args would be passed either in new Model($args) or Model::getInstance($args)

-Mike
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev


  
_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to