getStartDate()->getTimezone()); $participationList = []; foreach ($participations as $participation) { if (!$participation instanceof AccompanyingPeriodParticipation) { throw new UnexpectedTypeException($participation, AccompanyingPeriodParticipation::class); } $personId = $participation->getPerson()->getId(); $participationList[$personId][] = $participation; } foreach ($participationList as $group) { if (count($group) > 1) { foreach ($group as $p) { $overlaps->add($p->getStartDate(), $p->getEndDate(), $p->getId()); } } } $overlaps->compute(); if ($overlaps->hasIntersections()) { foreach ($overlaps->getIntersections() as list($start, $end, $ids)) { $msg = $end === null ? $constraint->message : $constraint->message; $this->context->buildViolation($msg) ->setParameters([ '{{ start }}' => $start->format('d-m-Y'), '{{ end }}' => $end === null ? null : $end->format('d-m-Y'), '{{ ids }}' => $ids, ]) ->addViolation(); } } } }