CommerceGuys\Addressing\Validator\Constraints\AddressFormatConstraintValidator::addViolation PHP Method

addViolation() protected method

Accounts for differences between Symfony versions.
protected addViolation ( string $field, string $message, mixed $invalidValue, AddressFormat $addressFormat )
$field string The field.
$message string The error message.
$invalidValue mixed The invalid, validated value.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.
    protected function addViolation($field, $message, $invalidValue, AddressFormat $addressFormat)
    {
        if ($this->context instanceof \Symfony\Component\Validator\Context\ExecutionContextInterface) {
            $this->context->buildViolation($message)->atPath('[' . $field . ']')->setInvalidValue($invalidValue)->addViolation();
        } else {
            $this->buildViolation($message)->atPath('[' . $field . ']')->setInvalidValue($invalidValue)->addViolation();
        }
    }