Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Validator;
|
Chris@0
|
13
|
Chris@0
|
14 use Doctrine\Common\Annotations\Reader;
|
Chris@0
|
15 use Symfony\Component\Translation\TranslatorInterface;
|
Chris@0
|
16 use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
|
Chris@0
|
17 use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
|
Chris@0
|
18 use Symfony\Component\Validator\Validator\ValidatorInterface;
|
Chris@0
|
19
|
Chris@0
|
20 /**
|
Chris@0
|
21 * A configurable builder for ValidatorInterface objects.
|
Chris@0
|
22 *
|
Chris@0
|
23 * @author Bernhard Schussek <bschussek@gmail.com>
|
Chris@0
|
24 */
|
Chris@0
|
25 interface ValidatorBuilderInterface
|
Chris@0
|
26 {
|
Chris@0
|
27 /**
|
Chris@0
|
28 * Adds an object initializer to the validator.
|
Chris@0
|
29 *
|
Chris@0
|
30 * @return $this
|
Chris@0
|
31 */
|
Chris@0
|
32 public function addObjectInitializer(ObjectInitializerInterface $initializer);
|
Chris@0
|
33
|
Chris@0
|
34 /**
|
Chris@0
|
35 * Adds a list of object initializers to the validator.
|
Chris@0
|
36 *
|
Chris@14
|
37 * @param ObjectInitializerInterface[] $initializers
|
Chris@0
|
38 *
|
Chris@0
|
39 * @return $this
|
Chris@0
|
40 */
|
Chris@0
|
41 public function addObjectInitializers(array $initializers);
|
Chris@0
|
42
|
Chris@0
|
43 /**
|
Chris@0
|
44 * Adds an XML constraint mapping file to the validator.
|
Chris@0
|
45 *
|
Chris@0
|
46 * @param string $path The path to the mapping file
|
Chris@0
|
47 *
|
Chris@0
|
48 * @return $this
|
Chris@0
|
49 */
|
Chris@0
|
50 public function addXmlMapping($path);
|
Chris@0
|
51
|
Chris@0
|
52 /**
|
Chris@0
|
53 * Adds a list of XML constraint mapping files to the validator.
|
Chris@0
|
54 *
|
Chris@14
|
55 * @param string[] $paths The paths to the mapping files
|
Chris@0
|
56 *
|
Chris@0
|
57 * @return $this
|
Chris@0
|
58 */
|
Chris@0
|
59 public function addXmlMappings(array $paths);
|
Chris@0
|
60
|
Chris@0
|
61 /**
|
Chris@0
|
62 * Adds a YAML constraint mapping file to the validator.
|
Chris@0
|
63 *
|
Chris@0
|
64 * @param string $path The path to the mapping file
|
Chris@0
|
65 *
|
Chris@0
|
66 * @return $this
|
Chris@0
|
67 */
|
Chris@0
|
68 public function addYamlMapping($path);
|
Chris@0
|
69
|
Chris@0
|
70 /**
|
Chris@0
|
71 * Adds a list of YAML constraint mappings file to the validator.
|
Chris@0
|
72 *
|
Chris@14
|
73 * @param string[] $paths The paths to the mapping files
|
Chris@0
|
74 *
|
Chris@0
|
75 * @return $this
|
Chris@0
|
76 */
|
Chris@0
|
77 public function addYamlMappings(array $paths);
|
Chris@0
|
78
|
Chris@0
|
79 /**
|
Chris@0
|
80 * Enables constraint mapping using the given static method.
|
Chris@0
|
81 *
|
Chris@0
|
82 * @param string $methodName The name of the method
|
Chris@0
|
83 *
|
Chris@0
|
84 * @return $this
|
Chris@0
|
85 */
|
Chris@0
|
86 public function addMethodMapping($methodName);
|
Chris@0
|
87
|
Chris@0
|
88 /**
|
Chris@0
|
89 * Enables constraint mapping using the given static methods.
|
Chris@0
|
90 *
|
Chris@14
|
91 * @param string[] $methodNames The names of the methods
|
Chris@0
|
92 *
|
Chris@0
|
93 * @return $this
|
Chris@0
|
94 */
|
Chris@0
|
95 public function addMethodMappings(array $methodNames);
|
Chris@0
|
96
|
Chris@0
|
97 /**
|
Chris@0
|
98 * Enables annotation based constraint mapping.
|
Chris@0
|
99 *
|
Chris@0
|
100 * @return $this
|
Chris@0
|
101 */
|
Chris@0
|
102 public function enableAnnotationMapping(Reader $annotationReader = null);
|
Chris@0
|
103
|
Chris@0
|
104 /**
|
Chris@0
|
105 * Disables annotation based constraint mapping.
|
Chris@0
|
106 *
|
Chris@0
|
107 * @return $this
|
Chris@0
|
108 */
|
Chris@0
|
109 public function disableAnnotationMapping();
|
Chris@0
|
110
|
Chris@0
|
111 /**
|
Chris@0
|
112 * Sets the class metadata factory used by the validator.
|
Chris@0
|
113 *
|
Chris@0
|
114 * @return $this
|
Chris@0
|
115 */
|
Chris@0
|
116 public function setMetadataFactory(MetadataFactoryInterface $metadataFactory);
|
Chris@0
|
117
|
Chris@0
|
118 /**
|
Chris@0
|
119 * Sets the cache for caching class metadata.
|
Chris@0
|
120 *
|
Chris@0
|
121 * @return $this
|
Chris@0
|
122 */
|
Chris@0
|
123 public function setMetadataCache(CacheInterface $cache);
|
Chris@0
|
124
|
Chris@0
|
125 /**
|
Chris@0
|
126 * Sets the constraint validator factory used by the validator.
|
Chris@0
|
127 *
|
Chris@0
|
128 * @return $this
|
Chris@0
|
129 */
|
Chris@0
|
130 public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory);
|
Chris@0
|
131
|
Chris@0
|
132 /**
|
Chris@0
|
133 * Sets the translator used for translating violation messages.
|
Chris@0
|
134 *
|
Chris@0
|
135 * @return $this
|
Chris@0
|
136 */
|
Chris@0
|
137 public function setTranslator(TranslatorInterface $translator);
|
Chris@0
|
138
|
Chris@0
|
139 /**
|
Chris@0
|
140 * Sets the default translation domain of violation messages.
|
Chris@0
|
141 *
|
Chris@0
|
142 * The same message can have different translations in different domains.
|
Chris@0
|
143 * Pass the domain that is used for violation messages by default to this
|
Chris@0
|
144 * method.
|
Chris@0
|
145 *
|
Chris@0
|
146 * @param string $translationDomain The translation domain of the violation messages
|
Chris@0
|
147 *
|
Chris@0
|
148 * @return $this
|
Chris@0
|
149 */
|
Chris@0
|
150 public function setTranslationDomain($translationDomain);
|
Chris@0
|
151
|
Chris@0
|
152 /**
|
Chris@0
|
153 * Builds and returns a new validator object.
|
Chris@0
|
154 *
|
Chris@0
|
155 * @return ValidatorInterface The built validator
|
Chris@0
|
156 */
|
Chris@0
|
157 public function getValidator();
|
Chris@0
|
158 }
|