diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index d67bcad..81ba74a 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -358,6 +358,7 @@ public function getEffect($effect) { public function getEffects() { if (!$this->effectsBag) { $this->effectsBag = new ImageEffectBag(\Drupal::service('plugin.manager.image.effect'), $this->effects); + $this->effectsBag->sort(); } return $this->effectsBag; } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index d5c46de..2d1af48 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -72,7 +72,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 b5ffb12..f75c7cc 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectBag.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectBag.php @@ -7,7 +7,6 @@ namespace Drupal\image; -use Drupal\Component\Utility\MapArray; use Drupal\Component\Plugin\DefaultPluginBag; /** @@ -51,10 +50,14 @@ public function updateConfiguration(array $configuration) { /** * {@inheritdoc} */ - public function sort() { - uasort($this->configurations, 'drupal_sort_weight'); - $this->instanceIDs = MapArray::copyValuesToKeys(array_keys($this->configurations)); - return $this; + public function sortHelper($aID, $bID) { + $a_weight = $this->get($aID)->getWeight(); + $b_weight = $this->get($bID)->getWeight(); + if ($a_weight == $b_weight) { + return 0; + } + + return ($a_weight < $b_weight) ? -1 : 1; } } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php index 698b1bb..fc7280e 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; } @@ -204,7 +204,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; }