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 MyrestHelper as a thin facade delegating to the new services, so downstream modules keep working.
  • Register each service in myrest.services.yml with only the dependencies it actually needs.
  • Deprecate the facade methods with @deprecated in myrest:1.1.0 and is removed from myrest:2.0.0 annotations.

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

Command icon 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

sergeydruua created an issue. See original summary.

  • sergeydruua committed be864c81 on 1.0.x
    Issue #3615029: Extract image, menu and page URL services from...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)