| @@ 53-73 (lines=21) @@ | ||
| 50 | $this->emailTemplatesConfigurationValidator = $emailTemplatesConfigurationValidator; |
|
| 51 | } |
|
| 52 | ||
| 53 | public function validate($value, Constraint $constraint) |
|
| 54 | { |
|
| 55 | /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */ |
|
| 56 | $violation = false; |
|
| 57 | ||
| 58 | try { |
|
| 59 | $decoded = $this->decodeJson($value); |
|
| 60 | $this->validateRoot($decoded); |
|
| 61 | } catch (AssertionException $exception) { |
|
| 62 | // method is not in the interface yet, but the old method is deprecated. |
|
| 63 | $violation = $this->context->buildViolation($exception->getMessage()); |
|
| 64 | $violation->atPath($exception->getPropertyPath()); |
|
| 65 | } catch (CoreInvalidArgumentException $exception) { |
|
| 66 | $violation = $this->context->buildViolation($exception->getMessage()); |
|
| 67 | } |
|
| 68 | ||
| 69 | if ($violation) { |
|
| 70 | // ensure we have a sensible path. |
|
| 71 | $violation->addViolation(); |
|
| 72 | } |
|
| 73 | } |
|
| 74 | ||
| 75 | private function decodeJson($rawValue) |
|
| 76 | { |
|
| @@ 71-89 (lines=19) @@ | ||
| 68 | $this->whitelistService = $whitelistService; |
|
| 69 | } |
|
| 70 | ||
| 71 | public function validate($value, Constraint $constraint) |
|
| 72 | { |
|
| 73 | /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */ |
|
| 74 | $violation = false; |
|
| 75 | ||
| 76 | try { |
|
| 77 | $this->validateRoot($value); |
|
| 78 | } catch (AssertionException $exception) { |
|
| 79 | // method is not in the interface yet, but the old method is deprecated. |
|
| 80 | $violation = $this->context->buildViolation($exception->getMessage()); |
|
| 81 | $violation->atPath($exception->getPropertyPath()); |
|
| 82 | } catch (CoreInvalidArgumentException $exception) { |
|
| 83 | $violation = $this->context->buildViolation($exception->getMessage()); |
|
| 84 | } |
|
| 85 | ||
| 86 | if ($violation) { |
|
| 87 | $violation->addViolation(); |
|
| 88 | } |
|
| 89 | } |
|
| 90 | ||
| 91 | public function validateRoot(array $configuration) |
|
| 92 | { |
|