public function validateConstraintWithCustomDomain(ExecutionContext $context) { $context->buildViolation('entity.custom-domain')->setTranslationDomain('custom-domain')->addViolation(); }
/** * @Assert\Callback */ public function validate(ExecutionContext $context) { $parentTaxon = $this->getParent(); while ($parentTaxon) { if ($parentTaxon == $this) { $context->buildViolation('Circular taxonomy reference detected. Please check your parent taxonomy.')->atPath('parent')->addViolation(); break; } $parentTaxon = $parentTaxon->getParent(); } }