function ResponsiveImageConfigUpdater::orderMultipliersNumerically

Same name and namespace in other branches
  1. 11.x core/modules/responsive_image/src/ResponsiveImageConfigUpdater.php \Drupal\responsive_image\ResponsiveImageConfigUpdater::orderMultipliersNumerically()

Re-order mappings by breakpoint ID and descending numeric multiplier order.

Parameters

\Drupal\responsive_image\ResponsiveImageStyleInterface $responsive_image_style: The responsive image style

Return value

bool Whether the responsive image style was updated.

@todo when removing this, evaluate if we need to keep it permanently to support an upgrade path (migration) from Drupal 7 picture module.

File

core/modules/responsive_image/src/ResponsiveImageConfigUpdater.php, line 52

Class

ResponsiveImageConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\responsive_image

Code

public function orderMultipliersNumerically(ResponsiveImageStyleInterface $responsive_image_style) : bool {
  $changed = FALSE;
  $original_mapping_order = $responsive_image_style->getImageStyleMappings();
  $responsive_image_style->removeImageStyleMappings();
  foreach ($original_mapping_order as $mapping) {
    $responsive_image_style->addImageStyleMapping($mapping['breakpoint_id'], $mapping['multiplier'], $mapping);
  }
  if ($responsive_image_style->getImageStyleMappings() !== $original_mapping_order) {
    $changed = TRUE;
  }
  $deprecations_triggered =& $this->triggeredDeprecations['3267870'][$responsive_image_style->id()];
  if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
    $deprecations_triggered = TRUE;
    @trigger_error(sprintf('The responsive image style multiplier re-ordering update for "%s" is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Profile, module and theme provided Responsive Image configuration should be updated. See https://www.drupal.org/node/3274803', $responsive_image_style->id()), E_USER_DEPRECATED);
  }
  return $changed;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.