Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Interface for proxy classes #11

Open
Mordred opened this issue Oct 2, 2013 · 4 comments
Open

Interface for proxy classes #11

Mordred opened this issue Oct 2, 2013 · 4 comments
Labels

Comments

@Mordred
Copy link
Contributor

Mordred commented Oct 2, 2013

It would be great if the generated proxy classes implement some interface. Then you will be able to test it as:

$isProxy = $instance instanceof SOME_INTERFACE;
@fprochazka
Copy link
Member

Yeah, I was thinking about it. Is it really neccesary? Maybe for get_class() calls.. what is the usecase for you?

@Mordred
Copy link
Contributor Author

Mordred commented Oct 2, 2013

Look at this method: http://api.nette.org/2.0/source-Application.UI.Presenter.php.html#501-517

It is using reflection for detecting "templates" directory. So when you use proxy you have to overload this method, overload getReflection() method or move all your template files inside cache directory.

Third option is strange :D But for first and second option you need to detect that you are inside proxy.

@fprochazka
Copy link
Member

Good point :) I could override the reflection to return only reflection of the proxied class.

@Mordred
Copy link
Contributor Author

Mordred commented Oct 2, 2013

OK, but getReflection() is available only in subclasses of Nette\Object or if the developer wrote it. What if the service doesn't have this method?

PS: Doctrine also implement interface in generated proxies.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants