From 6a41deb798aab55ca67da758194fc030cdc32569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Thu, 15 Aug 2024 22:45:30 +0200 Subject: [PATCH] Better reordering of menu items --- src/EventSubscriber/OrderShowMenuSubscriber.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EventSubscriber/OrderShowMenuSubscriber.php b/src/EventSubscriber/OrderShowMenuSubscriber.php index e48b219..a77827e 100644 --- a/src/EventSubscriber/OrderShowMenuSubscriber.php +++ b/src/EventSubscriber/OrderShowMenuSubscriber.php @@ -41,11 +41,11 @@ public function addEditButton(OrderShowMenuBuilderEvent $event): void ->setLabelAttribute('color', 'purple') ; - $sort = [self::MENU_ITEM_KEY, 'order_history', 'cancel']; - $rest = array_diff(array_keys($menu->getChildren()), $sort); + $sort = array_keys($menu->getChildren()); + array_unshift($sort, self::MENU_ITEM_KEY); try { - $event->getMenu()->reorderChildren(array_merge($sort, $rest)); + $event->getMenu()->reorderChildren($sort); } catch (\InvalidArgumentException) { } }