violations = new ConstraintViolationList(); } /** * {@inheritdoc} */ public function setNode(mixed $value, ?object $object, ?MetadataInterface $metadata, string $propertyPath): void { $this->value = $value; $this->object = $object; $this->metadata = $metadata; $this->propertyPath = $propertyPath; } /** * {@inheritdoc} */ public function setConstraint(Constraint $constraint): void { $this->constraint = $constraint; } /** * {@inheritdoc} */ public function addViolation(string $message, array $params = []): void { $this->violations->add(new ConstraintViolation($this->translator->trans($message, $params, $this->translationDomain), $message, $params, $this->root, $this->propertyPath, $this->value, NULL, NULL, $this->constraint)); } /** * {@inheritdoc} */ public function buildViolation(string $message, array $parameters = []): ConstraintViolationBuilderInterface { return new ConstraintViolationBuilder($this->violations, $this->constraint, $message, $parameters, $this->root, $this->propertyPath, $this->value, $this->translator, $this->translationDomain); } /** * {@inheritdoc} */ public function getViolations(): ConstraintViolationListInterface { return $this->violations; } /** * {@inheritdoc} */ public function getValidator(): ValidatorInterface { return $this->validator; } /** * {@inheritdoc} */ public function getRoot(): mixed { return $this->root; } /** * {@inheritdoc} */ public function getValue(): mixed { return $this->value; } /** * {@inheritdoc} */ public function getObject(): ?object { return $this->object; } /** * {@inheritdoc} */ public function getMetadata(): ?MetadataInterface { return $this->metadata; } /** * {@inheritdoc} */ public function getGroup(): ?string { return Constraint::DEFAULT_GROUP; } /** * {@inheritdoc} */ public function setGroup(?string $group): void { $this->group = $group; } /** * {@inheritdoc} */ public function getClassName(): ?string { return get_class($this->object); } /** * {@inheritdoc} */ public function getPropertyName(): ?string { return $this->metadata instanceof PropertyMetadataInterface ? $this->metadata->getPropertyName() : NULL; } /** * {@inheritdoc} */ public function getPropertyPath(string $subPath = ''): string { return PropertyPath::append($this->propertyPath, $subPath); } /** * {@inheritdoc} */ public function markConstraintAsValidated(string $cacheKey, string $constraintHash): void { $this->validatedConstraints[$cacheKey . ':' . $constraintHash] = TRUE; } /** * {@inheritdoc} */ public function isConstraintValidated(string $cacheKey, string $constraintHash): bool { return isset($this->validatedConstraints[$cacheKey . ':' . $constraintHash]); } /** * {@inheritdoc} */ public function markGroupAsValidated(string $cacheKey, string $groupHash): void { $this->validatedObjects[$cacheKey][$groupHash] = TRUE; } /** * {@inheritdoc} */ public function isGroupValidated(string $cacheKey, string $groupHash): bool { return isset($this->validatedObjects[$cacheKey][$groupHash]); } /** * {@inheritdoc} */ public function markObjectAsInitialized(string $cacheKey): void { throw new \LogicException(ExecutionContextInterface::class . '::markObjectAsInitialized is unsupported.'); } /** * {@inheritdoc} */ public function isObjectInitialized(string $cacheKey): bool { throw new \LogicException(ExecutionContextInterface::class . '::isObjectInitialized is unsupported.'); } /** * Clone this context. */ public function __clone(): void { $this->violations = clone $this->violations; } }