Problem/Motivation
Currently, a lot of logic for loading and examining entities is included in the the central ContentLoader class. As this develops further it continues to expand the dependencies and requirements injected into the class, also making testing difficult to achieve effectively.
Having this logic buried within the ContentLoader class also makes it inaccessible in other places that might benefit from the same lookups and loading as described in these related issues:
- #2893055: Expand logic for identifying content to update
- #2879468: Nodes Cannot Create Menu Links Automatically
- #2894614: Allow configuration of properties used to match existing entities
- #2876203: Support load user entity by name process callback
- #2917940: Change reference callback to load entity directly
Proposed resolution
Extract logic to interact directly with entity definitions and storage handlers into a separate helper service to reduce redundancy and tight coupling of services that is making effective unit testing difficult. Using this separation of dependencies, more unit testing should be added to confirm existing functionality within the ContentLoader class.
Remaining tasks
- Create and extract entity logic into new EntityLoadHelper service
- Refactor required services and related loading of these dependencies to better support mocking in unit tests
- Implement unit tests to confirm existing functionality
- Extend usage of new service and features into related tickets
API changes
- Introduce new
EntityLoadHelperservice - Update ContentLoader dependency injection requirements
- Refactor existing unit tests
Data model changes
TBD
| Comment | File | Size | Author |
|---|
Comments
Comment #2
sluceroThis work needs some clean-up to separate and better describe everything being done, but I'd rather get it off of my local so it is available for review as well.
It targets a lot of the goals of this issue, but needs a bit more work as a couple of the tests are still failing and need debugging as to why.
Included in this is also some refactoring of how events are being created along with a variety of other changes to publicly available functions, so it still needs to be reviewed for any breaking changes that may be introduced that need documenting.
Comment #4
sluceroMost of the work from #2 here has been split and refined across #2949808-2: Implement ContainerInjectionInterface for ContentLoader and #2949902-2: Consolidate Event Dispatching Into Consistent Pattern. Any review and follow-up should likely go in one of those unless focused on the task as a whole.
Since the patch attached above is no longer applicable, I'm hiding it from the list.
Comment #5
sluceroComment #6
sluceroThe majority of the work actually described here related to the new
EntityLoadHelperservice has been completed and merged in as part of #2949808: Implement ContainerInjectionInterface for ContentLoader. The remaining pieces of the original patch posted here related to the event dispatching system have been split out into #2949902: Consolidate Event Dispatching Into Consistent Pattern where they may be completed independently moving forward.This work represents a significant amount of refactoring work and is being pulled into a new
8.x-1.0-alpha4release.