[POC] Objectified module management #271
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The idea of this POC is to replace the module management system with an object oriented approach. This eases understanding on how plugins and the core interact and removes some code from the huge qa-base.php bag. The code is also encapsulated, information is hidden as much as possible, many calls such as
method_exists
are removed, etc.Sadly, this is everywhere in the core, so the minimal atomic change to make would impact everywhere and leave non-working sections. That's the reason of the huge commit. So get a comfortable chair and some popcorn. Needless to say, don't expect documented code, as this is just a POC. However, you can enjoy some diagrams :)
These are some random notes I've taken while making the changes:
$pluginManager
should be a member of a singleton application instance but that is part of a different pull requestThese are the steps involved in plugin initialization:
The post initialization is actually a one level dependency management approach. If plugin B depends on A, then B can use A during post initialization. The thing is that if a plugin C depends on B there is no post post initialization. That could be solved making each plugin explicitly mention their dependents and running the initialization in steps, being the amount of steps the longer dependency chain. I was just a bit lazy to work on that and wasn't so critical.
Class diagram:
Gliffy Source: https://gist.github.com/pupi1985/82fb76a90640cce3c1f9#file-classdiagram-gliffy
And a short flow diagram about plugin initialization: http://yuml.me/edit/42e2816e
I guess something similar can be done to overrides and phrases but this seemed to be the first testable checkpoint. Layers are being discussed in a different pull request.