From b0d29eaeaf110b9949f03b43fed2450393f0efc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 8 Sep 2022 00:35:39 +0200 Subject: [PATCH] Dont change the original collection when calling getOrderdetails with $hide_obsolete = true This caused the orderdetails tab to be hidden on part info, when the orderdetail was obsolete --- src/Entity/Parts/PartTraits/OrderTrait.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Entity/Parts/PartTraits/OrderTrait.php b/src/Entity/Parts/PartTraits/OrderTrait.php index 79947596..a46b1f1e 100644 --- a/src/Entity/Parts/PartTraits/OrderTrait.php +++ b/src/Entity/Parts/PartTraits/OrderTrait.php @@ -44,6 +44,7 @@ namespace App\Entity\Parts\PartTraits; use App\Entity\PriceInformations\Orderdetail; use App\Security\Annotations\ColumnSecurity; +use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Validator\Constraints as Assert; use function count; use Doctrine\Common\Collections\Collection; @@ -129,14 +130,9 @@ trait OrderTrait { //If needed hide the obsolete entries if ($hide_obsolete) { - $orderdetails = $this->orderdetails; - foreach ($orderdetails as $key => $details) { - if ($details->getObsolete()) { - unset($orderdetails[$key]); - } - } - - return $orderdetails; + return $this->orderdetails->filter(function (Orderdetail $orderdetail) { + return ! $orderdetail->getObsolete(); + }); } return $this->orderdetails;