123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <?php
- namespace Symfony\Component\Validator;
- class ConstraintViolation implements ConstraintViolationInterface
- {
- private $message;
- private $messageTemplate;
- private $parameters;
- private $plural;
- private $root;
- private $propertyPath;
- private $invalidValue;
- private $constraint;
- private $code;
- private $cause;
-
- public function __construct($message, $messageTemplate, array $parameters, $root, $propertyPath, $invalidValue, $plural = null, $code = null, Constraint $constraint = null, $cause = null)
- {
- $this->message = $message;
- $this->messageTemplate = $messageTemplate;
- $this->parameters = $parameters;
- $this->plural = $plural;
- $this->root = $root;
- $this->propertyPath = $propertyPath;
- $this->invalidValue = $invalidValue;
- $this->constraint = $constraint;
- $this->code = $code;
- $this->cause = $cause;
- }
-
- public function __toString()
- {
- if (\is_object($this->root)) {
- $class = 'Object('.\get_class($this->root).')';
- } elseif (\is_array($this->root)) {
- $class = 'Array';
- } else {
- $class = (string) $this->root;
- }
- $propertyPath = (string) $this->propertyPath;
- $code = $this->code;
- if ('' !== $propertyPath && '[' !== $propertyPath[0] && '' !== $class) {
- $class .= '.';
- }
- if (!empty($code)) {
- $code = ' (code '.$code.')';
- }
- return $class.$propertyPath.":\n ".$this->getMessage().$code;
- }
-
- public function getMessageTemplate()
- {
- return $this->messageTemplate;
- }
-
- public function getMessageParameters()
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7, to be removed in 3.0. Use the ConstraintViolation::getParameters() method instead.', E_USER_DEPRECATED);
- return $this->parameters;
- }
-
- public function getParameters()
- {
- return $this->parameters;
- }
-
- public function getMessagePluralization()
- {
- @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7, to be removed in 3.0. Use the ConstraintViolation::getPlural() method instead.', E_USER_DEPRECATED);
- return $this->plural;
- }
-
- public function getPlural()
- {
- return $this->plural;
- }
-
- public function getMessage()
- {
- return $this->message;
- }
-
- public function getRoot()
- {
- return $this->root;
- }
-
- public function getPropertyPath()
- {
- return $this->propertyPath;
- }
-
- public function getInvalidValue()
- {
- return $this->invalidValue;
- }
-
- public function getConstraint()
- {
- return $this->constraint;
- }
-
- public function getCause()
- {
- return $this->cause;
- }
-
- public function getCode()
- {
- return $this->code;
- }
- }
|