| @@ 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 | { |
|
| @@ 58-76 (lines=19) @@ | ||
| 55 | $this->secondFactorTypeService = $secondFactorTypeService; |
|
| 56 | } |
|
| 57 | ||
| 58 | public function validate($value, Constraint $constraint) |
|
| 59 | { |
|
| 60 | /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */ |
|
| 61 | $violation = false; |
|
| 62 | ||
| 63 | try { |
|
| 64 | $this->validateRoot($value); |
|
| 65 | } catch (AssertionException $exception) { |
|
| 66 | // method is not in the interface yet, but the old method is deprecated. |
|
| 67 | $violation = $this->context->buildViolation($exception->getMessage()); |
|
| 68 | $violation->atPath($exception->getPropertyPath()); |
|
| 69 | } catch (CoreInvalidArgumentException $exception) { |
|
| 70 | $violation = $this->context->buildViolation($exception->getMessage()); |
|
| 71 | } |
|
| 72 | ||
| 73 | if ($violation) { |
|
| 74 | $violation->addViolation(); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | public function validateRoot(array $configuration) |
|
| 79 | { |
|