8000 fixed deprecation notice · symfony/symfony@1adf54b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1adf54b

Browse files
committed
fixed deprecation notice
1 parent 97cff75 commit 1adf54b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Symfony/Component/Validator/Constraints/LengthValidator.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,19 @@ public function validate($value, Constraint $constraint)
6565
}
6666

6767
if ($invalidCharset) {
68-
$this->buildViolation($constraint->charsetMessage)
69-
->setParameter('{{ value }}', $this->formatValue($stringValue))
70-
->setParameter('{{ charset }}', $constraint->charset)
71-
->setInvalidValue($value)
72-
->addViolation();
68+
if ($this->context instanceof ExecutionContextInterface) {
69+
$this->context->buildViolation($constraint->charsetMessage)
70+
->setParameter('{{ value }}', $this->formatValue($stringValue))
71+
->setParameter('{{ charset }}', $constraint->charset)
72+
->setInvalidValue($value)
73+
->addViolation();
74+
} else {
75+
$this->buildViolation($constraint->charsetMessage)
76+
->setParameter('{{ value }}', $this->formatValue($stringValue))
77+
->setParameter('{{ charset }}', $constraint->charset)
78+
->setInvalidValue($value)
79+
->addViolation();
80+
}
7381

7482
return;
7583
}

0 commit comments

Comments
 (0)
0