-
Notifications
You must be signed in to change notification settings - Fork 262
[3.0] Subaction interface #8164
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
base: release-3.0
Are you sure you want to change the base?
Conversation
74b3920 to
10e6949
Compare
10e6949 to
99321ad
Compare
|
@tyrsson I would like your thoughts on this implementation, how it might work with PSR-14. Should we stay with the current way off plastering hooks everywhere (nearly one for each sub-action implementation) or would a single entry point be best, where a conditional check for the right class instance must be made? Or perhaps this approach is bad and should be scrapped? |
|
Will try to look into it tomorrow. Here is some general thoughts on it though. Your psr 14 events/listeners can become first class actors rather than simply a means to get arrays passed around. The subactions could actually be executed as a psr 14 event. Mod authors then just attach listeners to said event. If they have a reason to do so. ie You are introducing a SubActionInterface paired with an expressing trait. Composition over inheritance. I like it. The application should only care that the expressing class honors the contract defined by the interface. That should be the only required check. Now, to get more specific than that you would need more than a single interface. Where subaction interface would be an extension of other interfaces. Say a ConfigVarAwareInterface, which means it's capable of returning a configvar array for consumption. That the application can depend on. It's the contract defined by that interface. Only an instanceof check is required to determine if this action/subaction provides any. As you are doing. SMF needs to be built to the interface, mod authors should be the only ones (generally speaking) typing more specific than the interface. As a general rule of thumb. SMF classes do about a 1000 more things than they should. SRP is a thing for a reason ;) |
|
Another minor thought in regards to naming. Its not very SMF but I would suggest either. SubActionProviderInterface |
|
@Sesquipedalian can I have your thoughts on this please? Do you think this could be a good change, having an interface to explicitly build sub-actions with? |
99321ad to
133e42e
Compare
Signed-off-by: John Rayes <[email protected]>
133e42e to
cb2b903
Compare
|
I like the idea, although I would have just called it SubActionInterface to line up the naming convention of ActionInterface. It feels like it needs a folder to group them, such as "SMF\Routable" or something. I would then suggest also implementing one for "area". |
Motivation
To cut down on the use of static properties as much as possible and implement well-defined methods for adding sub-actions. The goal here would be to hook into one entry point probably in
SMF\Forumwhere new functions could be implemented that return the instance of the action class.Definition
This is the interface for future reference (I suck at naming things):
Action objects that use sub-actions are encouraged to implement this.
Example Usage
In this example:
SomeActionClassimplementsProvidesSubActionInterfaceand usesProvidesSubActionTrait.addSubActionmethod.setDefaultSubActionmethod.executemethod calls the appropriate sub-action based on the 'sa' request parameter.doSomethinganddoAnotherThing) are defined within the class.This should give you a basic idea of how to use the provided trait and interface.