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.
This commit is contained in:
Julien Fastré 2024-02-13 21:04:22 +01:00
parent 510023d630
commit 8a2f3d3dd0
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -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;
}