refactor: #3628879 Replace remaining global service calls and entity-storage injection

Inject the entity type manager into the image formatters and caption service, and inject existing services into the hook classes. Preserve formatter settings, rendering and cacheability.

Thanks for reviewing the recent MRs. These remaining dependency-injection findings were in the original CI reports. As the coding cleanup is now merged, this is a separate follow-up.

Validation:

  • Nine Kernel cases pass on Drupal 10 and 11, including the pending MRs combined.
  • Resolves 13 PHPStan dependency-injection findings without suppressions.
  • The pending MR diffs apply alongside this change in either order.
  • Combined formatter serialization checks pass on both Drupal versions.

Constructor dependencies and protected storage properties change; custom instantiation or subclasses may require updates. The separate serialization fix in #3628779 remains unchanged.

Issue: https://www.drupal.org/project/glightbox/issues/3628879 Equivalent video-module issue: https://www.drupal.org/project/glightbox_media_video/issues/3628876

AI-Generated: Yes (Codex prepared the changes and verification).

Merge request reports

Loading
Loading