Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance Chaining for mods #3262

Open
Vekseid opened this issue Nov 28, 2018 · 2 comments
Open

Inheritance Chaining for mods #3262

Vekseid opened this issue Nov 28, 2018 · 2 comments

Comments

@Vekseid
Copy link
Contributor

Vekseid commented Nov 28, 2018

For #3259

Xenforo does this. Everything is baked into classes, methods are broken apart, stuff modifies class properties wherever possible.

Well, that's the ideal. Xenforo fails in the last part in a lot of places. >_>

I think we can make it a bit easier to use / develop for than Xenforo though, at least for this.

The way it works is that, rather than extending the class directly, you extend a shortcut. This shortcut gets expanded by the autoloader to point to either the next modification file in the chain, or to the core unmodified file itself.

There are a few things I think we can vastly improve over Xenforo for ease of development, here. We can have people specify priority and the true overrided class in comments, for example. When a mod gets activated or deactivated, it rebuilds the site's autoloader chain cache accordingly.

@emanuele45
Copy link
Contributor

I'm indeed not familiar with xf way.
Is there any example around the net?

One thing I introduced some time back are "events" (well, probably not the best name but it seemed to fit), where the event can expose to the addon almost anything from the class it is called from (and on-demand) including private/protected properties, allowing extensions to act like they were directly modifying the class code.
By design I limited this interaction to controllers (but considering how controllers still do much more than they are supposed to, changing it may be feasible) and properties (i.e. it's not possible to replace methods, and I think this should be kept that way), I didn't introduce proority to avoid further complexity, but it should be easy.

@Vekseid
Copy link
Contributor Author

Vekseid commented May 21, 2019

I guess the proper term is class proxy:

https://sourcemaking.com/design_patterns/proxy/php

May try editing the autoloader once I start integrating code.

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

No branches or pull requests

2 participants