Inject dependencies in Drupal\image\Plugin\Field\FieldFormatter\ImageFormatterBase

Created on 12 October 2023, about 1 year ago

Problem/Motivation

I was extending this formatter to create a new image formatter and find the issue that this core field formatted is not using dependency injection at
core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php

<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
 $image_styles = image_style_options(FALSE);
    $description_link = Link::fromTextAndUrl(
      $this->t('Configure Image Styles'),
      Url::fromRoute('entity.image_style.collection')
    );

 if ($style_id && $style = ImageStyle::load($style_id)) {
      if (!empty($dependencies[$style->getConfigDependencyKey()][$style->getConfigDependencyName()])) {
        $replacement_id = $this->imageStyleStorage->getReplacementId($style_id);
   

Proposed resolution

1. To use dependency injection for using Drupal services.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component
Image module 

Last updated about 23 hours ago

Created by

🇮🇳India adwivedi008

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024