From 8a2f3d3dd0979b38f2715a2afb5fe8e0abca4038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 13 Feb 2024 21:04:22 +0100 Subject: [PATCH] Simplify setCenters method and remove readonly property The commit simplifies the setCenters method in the ThirdParty class by directly assigning the incoming centers collection to the $centers property. Additionally, the readonly keyword has been removed from the $centers property declaration, allowing its value to be modified. --- .../ChillThirdPartyBundle/Entity/ThirdParty.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index ee8065662..56a2e4dcd 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -149,7 +149,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin * * @ORM\JoinTable(name="chill_3party.party_center") */ - private readonly Collection $centers; + private Collection $centers; /** * Contact Persons: One Institutional ThirdParty has Many Contact Persons. @@ -691,15 +691,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface, \Strin */ public function setCenters(Collection $centers) { - foreach ($centers as $center) { - $this->addCenter($center); - } - - foreach ($this->centers as $center) { - if (false === $centers->contains($center)) { - $this->removeCenter($center); - } - } + $this->centers = $centers; return $this; }