@@ -86,7 +86,14 @@ configure the locations of these files::
86
86
The AnnotationLoader
87
87
--------------------
88
88
89
- At last, the component provides an
89
+ .. deprecated :: 6.4
90
+
91
+ The :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AnnotationLoader `
92
+ is deprecated since Symfony 6.4, use the
93
+ :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AttributeLoader `
94
+ instead.
95
+
96
+ The component provides an
90
97
:class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AnnotationLoader ` to get
91
98
the metadata from the attributes of the class::
92
99
@@ -111,8 +118,44 @@ To enable the annotation loader, call the
111
118
To disable the annotation loader after it was enabled, call
112
119
:method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAnnotationMapping `.
113
120
121
+ .. deprecated :: 6.4
122
+
123
+ The :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::enableAnnotationMapping `
124
+ and :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAnnotationMapping `
125
+ methods are deprecated since Symfony 6.4, use the
126
+ :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::enableAttributeMapping `
127
+ and :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAttributeMapping `
128
+ methods instead.
129
+
114
130
.. include :: /_includes/_annotation_loader_tip.rst.inc
115
131
132
+ The AttributeLoader
133
+ -------------------
134
+
135
+ .. versionadded :: 6.4
136
+
137
+ The :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AttributeLoader `
138
+ was introduced in Symfony 6.4.
139
+
140
+ The component provides an
141
+ :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AttributeLoader ` to get
142
+ the metadata from the attributes of the class. For example::
143
+
144
+ use Symfony\Component\Validator\Constraints as Assert;
145
+ // ...
146
+
147
+ class User
148
+ {
149
+ #[Assert\NotBlank]
150
+ protected string $name;
151
+ }
152
+
153
+ To enable the attribute loader, call the
154
+ :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::enableAttributeMapping ` method.
155
+
156
+ To disable the annotation loader after it was enabled, call
157
+ :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAttributeMapping `.
158
+
116
159
Using Multiple Loaders
117
160
----------------------
118
161
@@ -126,7 +169,7 @@ multiple mappings::
126
169
use Symfony\Component\Validator\Validation;
127
170
128
171
$validator = Validation::createValidatorBuilder()
129
- ->enableAnnotationMapping(true )
172
+ ->enableAttributeMapping( )
130
173
->addMethodMapping('loadValidatorMetadata')
131
174
->addXmlMapping('validator/validation.xml')
132
175
->getValidator();
0 commit comments