diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 0b6efe328..ae7b927a6 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -53,7 +53,7 @@ use Symfony\Component\Validator\GroupSequenceProviderInterface; use UnexpectedValueException; -use function in_array; +use function array_key_exists; use const SORT_REGULAR; /** @@ -644,16 +644,18 @@ class AccompanyingPeriod implements public function getCenters(): ?iterable { + $centers = []; + foreach ($this->getPersons() as $person) { if ( - !in_array($person->getCenter(), $centers ?? [], true) - && null !== $person->getCenter() + null !== $person->getCenter() + && !array_key_exists(spl_object_hash($person->getCenter()), $centers) ) { - $centers[] = $person->getCenter(); + $centers[spl_object_hash($person->getCenter())] = $person->getCenter(); } } - return $centers ?? null; + return array_values($centers); } /**