|
1 <?php |
|
2 |
|
3 namespace Symfony\Component\Validator; |
|
4 |
|
5 /* |
|
6 * This file is part of the Symfony package. |
|
7 * |
|
8 * (c) Fabien Potencier <fabien@symfony.com> |
|
9 * |
|
10 * For the full copyright and license information, please view the LICENSE |
|
11 * file that was distributed with this source code. |
|
12 */ |
|
13 |
|
14 use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; |
|
15 |
|
16 /** |
|
17 * Default implementation of ValidatorContextInterface |
|
18 * |
|
19 * @author Bernhard Schussek <bernhard.schussek@symfony.com> |
|
20 */ |
|
21 class ValidatorContext implements ValidatorContextInterface |
|
22 { |
|
23 /** |
|
24 * The class metadata factory used in the new validator |
|
25 * @var ClassMetadataFactoryInterface |
|
26 */ |
|
27 protected $classMetadataFactory = null; |
|
28 |
|
29 /** |
|
30 * The constraint validator factory used in the new validator |
|
31 * @var ConstraintValidatorFactoryInterface |
|
32 */ |
|
33 protected $constraintValidatorFactory = null; |
|
34 |
|
35 /** |
|
36 * @inheritDoc |
|
37 */ |
|
38 public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory) |
|
39 { |
|
40 $this->classMetadataFactory = $classMetadataFactory; |
|
41 |
|
42 return $this; |
|
43 } |
|
44 |
|
45 /** |
|
46 * @inheritDoc |
|
47 */ |
|
48 public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory) |
|
49 { |
|
50 $this->constraintValidatorFactory = $constraintValidatorFactory; |
|
51 |
|
52 return $this; |
|
53 } |
|
54 |
|
55 /** |
|
56 * @inheritDoc |
|
57 */ |
|
58 public function getValidator() |
|
59 { |
|
60 return new Validator( |
|
61 $this->classMetadataFactory, |
|
62 $this->constraintValidatorFactory |
|
63 ); |
|
64 } |
|
65 |
|
66 /** |
|
67 * Returns the class metadata factory used in the new validator |
|
68 * |
|
69 * @return ClassMetadataFactoryInterface The factory instance |
|
70 */ |
|
71 public function getClassMetadataFactory() |
|
72 { |
|
73 return $this->classMetadataFactory; |
|
74 } |
|
75 |
|
76 /** |
|
77 * Returns the constraint validator factory used in the new validator |
|
78 * |
|
79 * @return ConstraintValidatorFactoryInterface The factory instance |
|
80 */ |
|
81 public function getConstraintValidatorFactory() |
|
82 { |
|
83 return $this->constraintValidatorFactory; |
|
84 } |
|
85 } |