DI in ResultSet?

Is there a proper way to provide the DI instance to all Model instances in ResultSet?

Would be great to have a simple syntax like this:

ModelName::query()->order('position')->limit(1)->execute($this->getDI());

The only way I can think of so far is to loop over the ResultSet and call setDI() for every Model separately.

Actually when you construct your model, then the model will uses the default di of your application.

The default di is defined as follows :

$Mydi = new Phalcon\Di();
/** put some stuff in the Di **/
 Di::setDefault($myDi)

When you use a phalcon application, this is done seamlessly for you.

But i'm on the purpose that you are using the models outside of a phalcon application, right ? Then just define your di as the default di and it will be used by your models.

Yes, you're right. I thought that the DI is not set because in models the magic overloading is not implemented like in other classes (apparently __get() is used for different purposes in models) and it the services have to be referenced via $this->getDI()->get('..'). However it would still be nice to avoid having a global DI instance.

Rinalds, with my example the di should be global

Yeah, exactly that I would like to avoid :) But it's a minor thing, I can always change the DI instance if I really need to.

Yeah, why not opening a NFC on github, but actually it is done like that to be easy to use.

And afaik that's the only one static thing into phalcon, but i agree, that's an easy way to do things, but not the best for interoperability