diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index 0625cdd..261b25a 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -85,7 +85,7 @@ public function form(array $form, array &$form_state) { // Render effects below parent elements. '#weight' => 5, ); - foreach ($this->entity->getEffects()->sort() as $effect) { + foreach ($this->entity->getEffects() as $effect) { $key = $effect->getUuid(); $form['effects'][$key]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$key]['weight'] : NULL; $form['effects'][$key]['label'] = array( diff --git a/core/modules/image/lib/Drupal/image/ImageEffectBag.php b/core/modules/image/lib/Drupal/image/ImageEffectBag.php index 0bdee3b..15407f9 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectBag.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectBag.php @@ -45,6 +45,8 @@ public function __construct(PluginManagerInterface $manager, array $configuratio $this->configurations = $configurations; if (!empty($configurations)) { + // Sort plugins by their weight. + uasort($this->configurations, 'drupal_sort_weight'); $this->instanceIDs = MapArray::copyValuesToKeys(array_keys($configurations)); } } @@ -110,15 +112,4 @@ public function setConfig(array $configuration) { return $instance_id; } - /** - * Sorts all image effect instances in this bag. - * - * @return self - */ - public function sort() { - uasort($this->configurations, 'drupal_sort_weight'); - $this->instanceIDs = MapArray::copyValuesToKeys(array_keys($this->configurations)); - return $this; - } - } diff --git a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php index 4683ff6..10e9ccc 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Core/Entity/ImageStyle.php @@ -284,7 +284,7 @@ public function createDerivative($original_uri, $derivative_uri) { if (!$image = image_load($original_uri)) { return FALSE; } - + // Apply effects in their order. foreach ($this->getEffects() as $effect) { $effect->applyEffect($image); } @@ -366,7 +366,7 @@ public function saveImageEffect(array $configuration) { */ public function getExportProperties() { $properties = parent::getExportProperties(); - $properties['effects'] = $this->getEffects()->sort()->export(); + $properties['effects'] = $this->getEffects()->export(); return $properties; } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php index 6bcf733..90b1533 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php @@ -156,7 +156,7 @@ function testStyle() { $effect_edits_order = array_keys($effect_edits); $order_correct = TRUE; $index = 0; - foreach ($style->getEffects()->sort() as $effect) { + foreach ($style->getEffects() as $effect) { if ($effect_edits_order[$index] != $effect->getPluginId()) { $order_correct = FALSE; } @@ -203,7 +203,7 @@ function testStyle() { $effect_edits_order = array_reverse($effect_edits_order); $order_correct = TRUE; $index = 0; - foreach ($style->getEffects()->sort() as $effect) { + foreach ($style->getEffects() as $effect) { if ($effect_edits_order[$index] != $effect->getPluginId()) { $order_correct = FALSE; }