8000 [Validator] Documented changes in the UPGRADE files · symfony/symfony@68d8018 · GitHub
[go: up one dir, main page]

Skip to content

Commit 68d8018

Browse files
committed
[Validator] Documented changes in the UPGRADE files
1 parent b1badea commit 68d8018

File tree

8 files changed

+407
-16
lines changed

8 files changed

+407
-16
lines changed

UPGRADE-2.5.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,93 @@ Validator
9595
$sequence = iterator_to_array($metadata->getGroupSequence());
9696
$result = array_map($callback, $sequence);
9797
```
98+
99+
* The array type hint in `ClassMetadata::setGroupSequence()` was removed. If
100+
you overwrite this method, make sure to remove the type hint as well. The
101+
method should now accept `GroupSequence` instances just as well as arrays.
102+
103+
Before:
104+
105+
```
106+
public function setGroupSequence(array $groups)
107+
{
108+
// ...
109+
}
110+
```
111+
112+
After:
113+
114+
```
115+
public function setGroupSequence($groupSequence)
116+
{
117+
// ...
118+
}
119+
```
120+
121+
* The validation engine in `Symfony\Component\Validator\Validator` was replaced
122+
by a new one in `Symfony\Component\Validator\Validator\RecursiveValidator`.
123+
With that change, several classes were deprecated that will be removed in
124+
Symfony 3.0. Also, the API of the validator was slightly changed. More
125+
details about that can be found in UPGRADE-3.0.
126+
127+
You can choose the desired API via the new "api" entry in
128+
app/config/config.yml:
129+
130+
```
131+
framework:
132+
validation:
133+
enabled: true
134+
api: auto
135+
```
136+
137+
When running PHP 5.3.9 or higher, Symfony will then use an implementation
138+
that supports both the old API and the new one:
139+
140+
```
141+
framework:
142+
validation:
143+
enabled: true
144+
api: 2.5-bc
145+
```
146+
147+
When running PHP lower than 5.3.9, that compatibility layer is not supported.
148+
On those versions, the old implementation will be used instead:
149+
150+
```
151+
framework:
152+
validation:
153+
enabled: true
154+
api: 2.4
155+
```
156+
157+
If you develop a new application that doesn't rely on the old API, you can
158+
also set the API to 2.5. In that case, the backwards compatibility layer
159+
will not be activated:
160+
161+
```
162+
framework:
163+
validation:
164+
enabled: true
165+
api: 2.5
166+
```
167+
168+
When using the validator outside of the Symfony full-stack framework, the
169+
desired API can be selected using `setApiVersion()` on the validator builder:
170+
171+
```
172+
// Previous implementation
173+
$validator = Validation::createValidatorBuilder()
174+
->setApiVersion(Validation::API_VERSION_2_4)
175+
->getValidator();
176+
177+
// New implementation with backwards compatibility support
178+
$validator = Validation::createValidatorBuilder()
179+
->setApiVersion(Validation::API_VERSION_2_5_BC)
180+
->getValidator();
181+
182+
// New implementation without backwards compatibility support
183+
$validator = Validation::createValidatorBuilder()
184+
->setApiVersion(Validation::API_VERSION_2_5)
185+
->getValidator();
186+
```
187+

0 commit comments

Comments
 (0)
0