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

  1. Run PHPStan with the Drupal extension against both classes in src/Plugin/Field/FieldFormatter.
  2. 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.

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
nick hope’s picture

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

  • levmyshkin committed fab5246f on 1.0.x authored by nick hope
    refactor: #3628876 Use dependency injection for image styles in video...
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)