getTeamer()) { return; } if (null === $dateFrom = $seasonAssignment->getDateFrom()) { return; } // A placement starting outside any season window belongs to no season, so there is // nothing to be the second of. if (null === $seasonYear = $this->seasonCalendar->seasonYearFor($dateFrom)) { return; } [$windowStart, $windowEnd] = $this->seasonCalendar->windowFor($seasonYear); $existing = $this->seasonAssignmentRepository->countInSeasonWindow( $teamer, $windowStart->toDateTimeImmutable(), $windowEnd->toDateTimeImmutable(), $seasonAssignment->getId() ); if (0 < $existing) { $this ->context ->buildViolation($constraint->message) ->addViolation() ; } } }