diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/FormError.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/FormError.php | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/FormError.php b/vendor/symfony/form/Symfony/Component/Form/FormError.php new file mode 100644 index 00000000..343165ca --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/FormError.php | |||
@@ -0,0 +1,105 @@ | |||
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\Form; | ||
13 | |||
14 | /** | ||
15 | * Wraps errors in forms | ||
16 | * | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class FormError | ||
20 | { | ||
21 | /** | ||
22 | * @var string | ||
23 | */ | ||
24 | private $message; | ||
25 | |||
26 | /** | ||
27 | * The template for the error message | ||
28 | * @var string | ||
29 | */ | ||
30 | protected $messageTemplate; | ||
31 | |||
32 | /** | ||
33 | * The parameters that should be substituted in the message template | ||
34 | * @var array | ||
35 | */ | ||
36 | protected $messageParameters; | ||
37 | |||
38 | /** | ||
39 | * The value for error message pluralization | ||
40 | * @var integer|null | ||
41 | */ | ||
42 | protected $messagePluralization; | ||
43 | |||
44 | /** | ||
45 | * Constructor | ||
46 | * | ||
47 | * Any array key in $messageParameters will be used as a placeholder in | ||
48 | * $messageTemplate. | ||
49 | * | ||
50 | * @param string $message The translated error message | ||
51 | * @param string|null $messageTemplate The template for the error message | ||
52 | * @param array $messageParameters The parameters that should be | ||
53 | * substituted in the message template. | ||
54 | * @param integer|null $messagePluralization The value for error message pluralization | ||
55 | * | ||
56 | * @see \Symfony\Component\Translation\Translator | ||
57 | */ | ||
58 | public function __construct($message, $messageTemplate = null, array $messageParameters = array(), $messagePluralization = null) | ||
59 | { | ||
60 | $this->message = $message; | ||
61 | $this->messageTemplate = $messageTemplate ?: $message; | ||
62 | $this->messageParameters = $messageParameters; | ||
63 | $this->messagePluralization = $messagePluralization; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Returns the error message | ||
68 | * | ||
69 | * @return string | ||
70 | */ | ||
71 | public function getMessage() | ||
72 | { | ||
73 | return $this->message; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Returns the error message template | ||
78 | * | ||
79 | * @return string | ||
80 | */ | ||
81 | public function getMessageTemplate() | ||
82 | { | ||
83 | return $this->messageTemplate; | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * Returns the parameters to be inserted in the message template | ||
88 | * | ||
89 | * @return array | ||
90 | */ | ||
91 | public function getMessageParameters() | ||
92 | { | ||
93 | return $this->messageParameters; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * Returns the value for error message pluralization. | ||
98 | * | ||
99 | * @return integer|null | ||
100 | */ | ||
101 | public function getMessagePluralization() | ||
102 | { | ||
103 | return $this->messagePluralization; | ||
104 | } | ||
105 | } | ||