Closed (fixed)
Project:
Diff
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
21 Jun 2016 at 09:45 UTC
Updated:
30 Aug 2016 at 15:54 UTC
Jump to comment: Most recent, Most recent file
At the moment EntityComparisonBase extends ControllerBase and is the base for Diff's controllers.
However, the logic inside EntityComparisonBase can be reused more widely than that. Therefore this logic should be converted into a new DiffEntityComparison service.
This will leave EntityComparisonBase empty of any significant logic of its own - so probably best to remove it.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | interdiff-2752725-24-27.txt | 31.25 KB | johnchque |
| #27 | turn-2752725-27.patch | 10.22 KB | johnchque |
| #24 | diff-entity-comparison-service-2752725-23.patch | 33.26 KB | jonathanshaw |
Comments
Comment #2
jonathanshawComment #3
jonathanshawI've made good progress with moving most of the controller logic into a service. Patch to follow in a few days.
Comment #4
miro_dietikerPromoting to major to reflect the architectural change discussion.
Our goal for a stable first diff release is definitively to provide stable extension points like this.
Comment #5
jonathanshawPatch coming on Monday. Code 99.9% ready.
Comment #6
rubela_shome commentedComment #8
rubela_shome commentedComment #10
jonathanshawHaving a lot of trouble getting a clean patch.
Comment #12
jonathanshawTest fails were caused by unintended removal of nonBreakingSpace property from EntityComparisonBase class
Comment #13
miro_dietikerMissing space after // and some missing final dots. And some more.
Comment #14
jonathanshawSorry about that. I've fixed the // spaces and dots in the controllers, and some other CS issue in EntityComparisonBase. I couldn't get codesniffer to run on the controllers though, it generated some exception. However the patch touches so few lines in the controllers that any other CS issues are almost certainly pre-existing.
Comment #16
johnchqueExtra indentation not needed.
The code looks nice, but please note that the configuration in general has changed to be per field instead of field type thus the patch should not be just rebased also updated with the latest fixes/commits/changes of the current code.
Comment #17
jonathanshawQuestion: is there any point to keeping EntityComparisonBase.php if all of its logic is moved into the service, and we only have one controller extending it? All it would do is invoke the service and make that available to controllers that extend it, but it's easy enough for the controllers to invoke the service themselves.
I think I should remove EntityComparisonBase in the next version of this patch?
Comment #18
johnchqueyes, sounds reasonable, I would vote for removing it. Better to wait till #2759627: Remove redundant NodeRevisionController is committed. :)
Comment #19
jonathanshawI also need to wait for #2768371: Make Diff Plugins property aware as that is changing EntityComparisonBase and the controllers.
I'm trying to figure out how to give the calling context (e.g. the controller) maximum control of the result. This allows people to build diffs in different contexts with modifications to the standard display.
The logic that decides which fields to show, what diff builder to use, and then builds the diff, (all in entityParser and diffBuilderManager) happens as part of a single recursive process, walking through the tree of fields and fields on referenced entities. We don't first do a setup, deciding what fields to compare and what builders to use, and then secondly build the comparisons. Therefore the calling context can't inspect the setup before the build, and override the choice of plugin or the configured settings on a plugin or anything else.
We could split it up, but that would require walking the fields tree twice. First we would build up a setup array storing what we planned to compare, loading the configured builders and settings, and return that array to the controller (which could modify it how it wanted). Second the controller would call a different method that went through the setup array and built the comparisons.
Is there an easier way?
Comment #20
miro_dietikerYeah agree that we can further rework the process and make it more modular and we should do so.
We could also simply offer a hook that allows to alter an intermediate state.
Most importantly, we want to create smaller issues and less monster refactorings.
Hope you can create specific issues with small goal descriptions. .-)
Comment #21
miro_dietikerI just committed the other issue about making the diff builder property aware, so this is unblocked now.
Please help to clean up all the things! :-)
Comment #22
jonathanshawOK, new patch. Restarted from scratch so no interdiff.
A very simple approach: All the methods from EntityComparisonBase went up into a DiffEntityComparison service, a couple of simple properties went down into GenericRevisionContoller, and EntityComparisonBase was removed.
Let's see what testbot says.
Comment #24
jonathanshawIt would help if I actually included DiffEntityComparison.php in the patch ...
Comment #25
miro_dietikerFor sake of alteration / subclassing, we recommend to add header/row keys. They're ignored by the table element, but they help accessing the items when extending.
Comment #26
jonathanshawFor #25 I've created #2784685: Streamline table header / row in GenericRevisionController as a follow-up, because a) those lines are just copied from the existing code, and (b) I'm not quite sure how to fix it. Is that acceptable?
Comment #27
johnchqueFixed the patch a bit. Cleaned the code a bit. :)
Comment #28
johnchqueAs this is not breaking tests and the header keys will be added in another issue. IMHO
Comment #30
miro_dietikerGreat, committed it is.