Problem/Motivation

PHPStan reports 13 dependency-injection findings in the image formatters, caption service and hook classes: stored entity-storage dependencies and global service calls.

Steps to reproduce

  1. Run PHPStan with the Drupal extension against the current 1.0.x source.
  2. Observe the dependency-injection findings in the formatters, caption service and hooks.

Proposed resolution

Inject the entity type manager and retrieve entity storage when needed. Inject the existing hook services and build image-style options through the injected manager. Preserve formatter settings and rendering behavior.

This follows the merged coding cleanup in #3628803. The separate serialization fix in #3628779 remains unchanged.

Equivalent video-module issue: #3628876.

Kernel tests pass on Drupal 10 and 11 for style options, rendering, dependencies, cache tags and service wiring. All 13 findings are resolved. Compatibility with the pending MRs has been checked.

Remaining tasks

Review and merge the MR.

API changes

Formatter constructors and protected storage properties change to use EntityTypeManagerInterface. The caption service gains an entity type manager argument, and hook classes gain service arguments. Custom instantiation or subclasses using these must be updated.

Issue fork glightbox-3628879

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

nick hope created an issue. See original summary.

nick hope’s picture

Assigned: nick hope » Unassigned
Issue summary: View changes
Status: Active » Needs review

levmyshkin made their first commit to this issue’s fork.

  • levmyshkin committed 19ca3a9f on 1.0.x authored by nick hope
    refactor: #3628879 Replace remaining global service calls and entity-...
levmyshkin’s picture

Status: Needs review » 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.

levmyshkin’s picture

Status: Fixed » Closed (fixed)