Problem/Motivation
MyrestHelper is a god object: about 6,600 lines and 139 methods in a single class, with 14 injected services. It mixes image handling, paragraph rendering, menu building, facets, reviews aggregation and price formatting. This makes the class impossible to unit test in isolation and forces every consumer to depend on the whole graph.
Proposed resolution
- Extract dedicated services:
MyrestImageBuilder,MyrestParagraphBuilder,MyrestMenuBuilder,MyrestFacetsBuilder,MyrestReviewsAggregator,MyrestPriceBuilder. - Keep
MyrestHelperas a thin facade delegating to the new services, so downstream modules keep working. - Register each service in
myrest.services.ymlwith only the dependencies it actually needs. - Deprecate the facade methods with
@deprecated in myrest:1.1.0 and is removed from myrest:2.0.0annotations.
Remaining tasks
Map every method to its target service, extract incrementally, and keep the facade covered by tests.
User interface changes
None.
API changes
New public services. MyrestHelper methods become deprecated but remain functional.
Issue fork myrest-3615029
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
sergeydruua commentedComment #6
sergeydruua commented