diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php index ad8f61c..24c4c8c 100644 --- a/core/modules/shortcut/src/Entity/Shortcut.php +++ b/core/modules/shortcut/src/Entity/Shortcut.php @@ -186,18 +186,23 @@ public function getCacheTags() { /** * Sort shortcut objects. * - * @param \Drupal\shortcut\ShortcutInterface[] $shortcuts - * The array of shortcut objects to sort. + * Callback for uasort(). + * + * @param array $a + * First item for comparison. + * @param array $b + * Second item for comparison. + * + * @return int + * The comparison result for uasort(). */ - public static function sort(array &$shortcuts) { - uasort($shortcuts, function (ShortcutInterface $a, ShortcutInterface $b) { - $a_weight = $a->getWeight(); - $b_weight = $b->getWeight(); - if ($a_weight == $b_weight) { - return strnatcasecmp($a->getTitle(), $b->getTitle()); - } - return ($a_weight < $b_weight) ? -1 : 1; - }); + public static function sort(ShortcutInterface $a, ShortcutInterface $b) { + $a_weight = $a->getWeight(); + $b_weight = $b->getWeight(); + if ($a_weight == $b_weight) { + return strnatcasecmp($a->getTitle(), $b->getTitle()); + } + return ($a_weight < $b_weight) ? -1 : 1; } } diff --git a/core/modules/shortcut/src/Entity/ShortcutSet.php b/core/modules/shortcut/src/Entity/ShortcutSet.php index abf953b..692e3ab 100644 --- a/core/modules/shortcut/src/Entity/ShortcutSet.php +++ b/core/modules/shortcut/src/Entity/ShortcutSet.php @@ -118,7 +118,7 @@ public function resetLinkWeights() { */ public function getShortcuts() { $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $this->id())); - Shortcut::sort($shortcuts); + uasort($shortcuts, array('\Drupal\shortcut\Entity\Shortcut', 'sort')); return $shortcuts; }