ConstraintViolation.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Symfony\Component\Validator;
  3. class ConstraintViolation
  4. {
  5. protected $messageTemplate;
  6. protected $messageParameters;
  7. protected $root;
  8. protected $propertyPath;
  9. protected $invalidValue;
  10. public function __construct($messageTemplate, array $messageParameters, $root, $propertyPath, $invalidValue)
  11. {
  12. $this->messageTemplate = $messageTemplate;
  13. $this->messageParameters = $messageParameters;
  14. $this->root = $root;
  15. $this->propertyPath = $propertyPath;
  16. $this->invalidValue = $invalidValue;
  17. }
  18. public function getMessageTemplate()
  19. {
  20. return $this->messageTemplate;
  21. }
  22. public function getMessageParameters()
  23. {
  24. return $this->messageParameters;
  25. }
  26. public function getMessage()
  27. {
  28. return str_replace(array_keys($sources), array_values($targets), $this->messageTemplate);
  29. }
  30. public function getRoot()
  31. {
  32. return $this->root;
  33. }
  34. public function getPropertyPath()
  35. {
  36. return $this->propertyPath;
  37. }
  38. public function getInvalidValue()
  39. {
  40. return $this->invalidValue;
  41. }
  42. }