Problem/Motivation
Both video formatters inject and store image-style entity storage, and use global service calls to build image-style options. PHPStan reports eight dependency-injection findings.
Steps to reproduce
- Run PHPStan with the Drupal extension against both classes in
src/Plugin/Field/FieldFormatter. - Observe the entity-storage injection, storage-property assignment and global service-call findings.
Proposed resolution
Inject the entity type manager and retrieve image-style storage when needed. Build the existing style options from that storage without version-dependent global calls.
Kernel tests pass on Drupal 10 and 11 for plugin creation, image-style options and summaries, including after serialization. All eight findings are resolved; two existing new static() warnings are outside this issue.
This follows the merged coding cleanup in #3628807. Compatibility with the other pending MRs has been checked.
Remaining tasks
Review and merge the MR.
API changes
Both constructors accept EntityTypeManagerInterface in place of image-style storage. The protected imageStyleStorage property becomes entityTypeManager. Custom instantiation or subclasses using these must be updated.
Issue fork glightbox_media_video-3628876
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 #3
nick hope commentedComment #4
nick hope commentedComment #7
levmyshkinComment #9
levmyshkin