Skip to content
Snippets Groups Projects

Improve expection message

3 files
+ 24
2
Compare changes
  • Side-by-side
  • Inline

Files

@@ -22,8 +22,12 @@ public function validate(mixed $value, Constraint $constraint): void {
$mapping = $this->context->getObject();
assert($mapping instanceof Mapping);
if ($mapping !== $this->context->getRoot()) {
throw new LogicException('The LangcodeRequiredIfTranslatableValues constraint can only operate on the root object being validated.');
$root = $this->context->getRoot();
if ($mapping !== $root) {
throw new LogicException(sprintf(
'The LangcodeRequiredIfTranslatableValues constraint is applied to \'%s\'. This constraint can only operate on the root object being validated.',
$root->getName() . '::' . $mapping->getName()
));
}
assert(in_array('langcode', $mapping->getValidKeys(), TRUE));
Loading