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:

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

  1. Create and extract entity logic into new EntityLoadHelper service
  2. Refactor required services and related loading of these dependencies to better support mocking in unit tests
  3. Implement unit tests to confirm existing functionality
  4. Extend usage of new service and features into related tickets

API changes

  • Introduce new EntityLoadHelper service
  • Update ContentLoader dependency injection requirements
  • Refactor existing unit tests

Data model changes

TBD

Comments

slucero created an issue. See original summary.

slucero’s picture

Status: Active » Needs review
StatusFileSize
new103.17 KB

This 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.

Status: Needs review » Needs work

The last submitted patch, 2: yaml_content--2949625-2--entity-load-helper.patch, failed testing. View results

slucero’s picture

Most 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.

slucero’s picture

Title: Move Entity Loading and Lookup info Helper Service » Move Entity Loading and Lookup into Helper Service
slucero’s picture

The majority of the work actually described here related to the new EntityLoadHelper service 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-alpha4 release.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.