Problem/Motivation

Because of this issue #2850373: Incompatibility with remote_stream_wrapper module in the ImageAPI Optimize module there is a need to replace the ImageStyle entity class with another which is compatible and implements ImageStyleInterface. However, the Focal Point module type-hints the concrete implementation \Drupal\image\Entity\ImageStyle in \Drupal\focal_point\Controller\FocalPointPreviewController::buildUrl

class FocalPointPreviewController extends ControllerBase {
...
  /**
   * Create the URL for a preview image including a query parameter.
   *
   * @param \Drupal\image\Entity\ImageStyle $style
     ...
   */
  protected function buildUrl(ImageStyle $style, File $image, $focal_point_value) {
    ...
  }
...
}

This causes the following TypeError

TypeError: Argument 1 passed to Drupal\focal_point\Controller\FocalPointPreviewController::buildUrl() must be an instance of Drupal\image\Entity\ImageStyle, instance of Drupal\entity_decorator\Entity\Replacements\ImageStyle given, called in /var/www/html/docroot/modules/contrib/focal_point/src/Controller/FocalPointPreviewController.php on line 108 in Drupal\focal_point\Controller\FocalPointPreviewController->buildUrl() (line 248 of /var/www/html/docroot/modules/contrib/focal_point/src/Controller/FocalPointPreviewController.php)

Proposed resolution

Change the type-hint to the interface \Drupal\image\ImageStyleInterface

Remaining tasks

Review needed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vtcore created an issue. See original summary.

vtcore’s picture

Patch provided for the current 8.x-1.x branch.

vtcore’s picture

Status: Active » Needs review
vtcore’s picture

Hey, anything else needed here?

  • bleen committed 03a78d9 on 8.x-1.x authored by vtcore
    Issue #3084662 by vtcore: Use ImageStyleInterface instead of ImageStyle...
bleen’s picture

Status: Needs review » Fixed

seems completely reasonable

  • bleen committed d698995 on 8.x-1.x
    Issue #3084662: cleanup unused code
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.