|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\Validator; |
|
13 |
|
14 /** |
|
15 * Represents a single violation of a constraint. |
|
16 * |
|
17 * @api |
|
18 */ |
|
19 class ConstraintViolation |
|
20 { |
|
21 protected $messageTemplate; |
|
22 protected $messageParameters; |
|
23 protected $root; |
|
24 protected $propertyPath; |
|
25 protected $invalidValue; |
|
26 |
|
27 public function __construct($messageTemplate, array $messageParameters, $root, $propertyPath, $invalidValue) |
|
28 { |
|
29 $this->messageTemplate = $messageTemplate; |
|
30 $this->messageParameters = $messageParameters; |
|
31 $this->root = $root; |
|
32 $this->propertyPath = $propertyPath; |
|
33 $this->invalidValue = $invalidValue; |
|
34 } |
|
35 |
|
36 /** |
|
37 * @return string |
|
38 * |
|
39 * @api |
|
40 */ |
|
41 public function getMessageTemplate() |
|
42 { |
|
43 return $this->messageTemplate; |
|
44 } |
|
45 |
|
46 /** |
|
47 * @return array |
|
48 * |
|
49 * @api |
|
50 */ |
|
51 public function getMessageParameters() |
|
52 { |
|
53 return $this->messageParameters; |
|
54 } |
|
55 |
|
56 /** |
|
57 * Returns the violation message. |
|
58 * |
|
59 * @return string |
|
60 * |
|
61 * @api |
|
62 */ |
|
63 public function getMessage() |
|
64 { |
|
65 return strtr($this->messageTemplate, $this->messageParameters); |
|
66 } |
|
67 |
|
68 public function getRoot() |
|
69 { |
|
70 return $this->root; |
|
71 } |
|
72 |
|
73 public function getPropertyPath() |
|
74 { |
|
75 return $this->propertyPath; |
|
76 } |
|
77 |
|
78 public function getInvalidValue() |
|
79 { |
|
80 return $this->invalidValue; |
|
81 } |
|
82 } |