render = $render; } public function validate($period, Constraint $constraint) { if (!$constraint instanceof LocationValidity) { throw new UnexpectedTypeException($constraint, LocationValidity::class); } if (!$period instanceof AccompanyingPeriod) { throw new UnexpectedValueException($period, AccompanyingPeriod::class); } if ($period->getLocationStatus() === 'person') { if ( null === $period->getOpenParticipationContainsPerson( $period->getPersonLocation() ) ) { $this->context->buildViolation($constraint->messagePersonLocatedMustBeAssociated) ->setParameter('{{ person_name }}', $this->render->renderString( $period->getPersonLocation(), [] )) ->addViolation(); } } if ( $period->getStep() !== AccompanyingPeriod::STEP_DRAFT && $period->getLocationStatus() === 'none' ) { $this->context ->buildViolation( $constraint->messagePeriodMustRemainsLocated ) ->addViolation(); } } }