ValidatorBuilderInterface.php 4.7 KB

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