Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 263 lines (194 sloc) 7.187 kb
6b601bd @jfsimon [http-foudation] Better accept header parsing
jfsimon authored
1 UPGRADE FROM 2.1 to 2.2
2 =======================
3
ded3a83 @jmikola [HttpFoundation] Document MongoDbSessionHandler changes
jmikola authored
4 ### HttpFoundation
5
6 * The MongoDbSessionHandler default field names and timestamp type have changed.
7
8 The `sess_` prefix was removed from default field names. The session ID is
9 now stored in the `_id` field by default. The session date is now stored as a
10 `MongoDate` instead of `MongoTimestamp`, which also makes it possible to use
11 TTL collections in MongoDB 2.2+ instead of relying on the `gc()` method.
12
bdf0334 @dlsniper Fixed the lap method. Added upgrade notes. Some CS fixes
dlsniper authored
13 * The Stopwatch functionality was moved from HttpKernel\Debug to its own component
14
0a380cf @fabpot [HttpFoundation] disabled Request _method feature by default (should now...
fabpot authored
15 * The _method request parameter support has been disabled by default (call
16 Request::enableHttpMethodParameterOverride() to enable it).
17
6b601bd @jfsimon [http-foudation] Better accept header parsing
jfsimon authored
18 #### Deprecations
19
20 * The `Request::splitHttpAcceptHeader()` is deprecated and will be removed in 2.3.
21
22 You should now use the `AcceptHeader` class which give you fluent methods to
23 parse request accept-* headers. Some examples:
24
25 ```
26 $accept = AcceptHeader::fromString($request->headers->get('Accept'));
27 if ($accept->has('text/html') {
28 $item = $accept->get('html');
29 $charset = $item->getAttribute('charset', 'utf-8');
30 $quality = $item->getQuality();
31 }
32
33 // accepts items are sorted by descending quality
34 $accepts = AcceptHeader::fromString($request->headers->get('Accept'))->all();
35
36 ```
97f6a1b @egeloen [Form] Update password type trimming to false
egeloen authored
37
38 ### Form
39
40 * The PasswordType is now not trimmed by default.
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
41
42 ### Validator
43
1db6f05 @ragtek Update UPGRADE-2.2.md
ragtek authored
44 * Interfaces were created for the classes `ConstraintViolation`,
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
45 `ConstraintViolationList`, `GlobalExecutionContext` and `ExecutionContext`.
46 If you type hinted against any of these classes, you are recommended to
47 type hint against their interfaces now.
48
49 Before:
50
51 ```
52 use Symfony\Component\Validator\ExecutionContext;
53
54 public function validateCustomLogic(ExecutionContext $context)
55 ```
56
57 After:
58
59 ```
fae3e35 @fabpot fixed typo
fabpot authored
60 use Symfony\Component\Validator\ExecutionContextInterface;
24c6530 @webmozart [Validator] Added instructions on integrating the latest Validator chang...
webmozart authored
61
62 public function validateCustomLogic(ExecutionContextInterface $context)
63 ```
64
65 For all implementations of `ConstraintValidatorInterface`, this change is
66 mandatory for the `initialize` method:
67
68 Before:
69
70 ```
71 use Symfony\Component\Validator\ConstraintValidatorInterface;
72 use Symfony\Component\Validator\ExecutionContext;
73
74 class MyValidator implements ConstraintValidatorInterface
75 {
76 public function initialize(ExecutionContext $context)
77 {
78 // ...
79 }
80 }
81 ```
82
83 After:
84
85 ```
86 use Symfony\Component\Validator\ConstraintValidatorInterface;
87 use Symfony\Component\Validator\ExecutionContextInterface;
88
89 class MyValidator implements ConstraintValidatorInterface
90 {
91 public function initialize(ExecutionContextInterface $context)
92 {
93 // ...
94 }
95 }
96 ```
97
98 #### Deprecations
99
100 * The interface `ClassMetadataFactoryInterface` was deprecated and will be
101 removed in Symfony 2.3. You should implement `MetadataFactoryInterface`
102 instead, which changes the name of the method `getClassMetadata` to
103 `getMetadataFor` and accepts arbitrary values (e.g. class names, objects,
104 numbers etc.). In your implementation, you should throw a
105 `NoSuchMetadataException` if you don't support metadata for the given value.
106
107 Before:
108
109 ```
110 use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
111
112 class MyMetadataFactory implements ClassMetadataFactoryInterface
113 {
114 public function getClassMetadata($class)
115 {
116 // ...
117 }
118 }
119 ```
120
121 After:
122
123 ```
124 use Symfony\Component\Validator\MetadataFactoryInterface;
125 use Symfony\Component\Validator\Exception\NoSuchMetadataException;
126
127 class MyMetadataFactory implements MetadataFactoryInterface
128 {
129 public function getMetadataFor($value)
130 {
131 if (is_object($value)) {
132 $value = get_class($value);
133 }
134
135 if (!is_string($value) || (!class_exists($value) && !interface_exists($value))) {
136 throw new NoSuchMetadataException(...);
137 }
138
139 // ...
140 }
141 }
142 ```
143
144 The return value of `ValidatorInterface::getMetadataFactory()` was also
145 changed to return `MetadataFactoryInterface`. Make sure to replace calls to
146 `getClassMetadata` by `getMetadataFor` on the return value of this method.
147
148 Before:
149
150 ```
151 $metadataFactory = $validator->getMetadataFactory();
152 $metadata = $metadataFactory->getClassMetadata('Vendor\MyClass');
153 ```
154
155 After:
156
157 ```
158 $metadataFactory = $validator->getMetadataFactory();
159 $metadata = $metadataFactory->getMetadataFor('Vendor\MyClass');
160 ```
161
162 * The class `GraphWalker` and the accessor `ExecutionContext::getGraphWalker()`
163 were deprecated and will be removed in Symfony 2.3. You should use the
164 methods `ExecutionContextInterface::validate()` and
165 `ExecutionContextInterface::validateValue()` instead.
166
167 Before:
168
169 ```
170 use Symfony\Component\Validator\ExecutionContext;
171
172 public function validateCustomLogic(ExecutionContext $context)
173 {
174 if (/* ... */) {
175 $path = $context->getPropertyPath();
176 $group = $context->getGroup();
177
178 if (!empty($path)) {
179 $path .= '.';
180 }
181
182 $context->getGraphWalker()->walkReference($someObject, $group, $path . 'myProperty', false);
183 }
184 }
185 ```
186
187 After:
188
189 ```
190 use Symfony\Component\Validator\ExecutionContextInterface;
191
192 public function validateCustomLogic(ExecutionContextInterface $context)
193 {
194 if (/* ... */) {
195 $context->validate($someObject, 'myProperty');
196 }
197 }
198 ```
199
200 * The method `ExecutionContext::addViolationAtSubPath()` was deprecated and
201 will be removed in Symfony 2.3. You should use `addViolationAt()` instead.
202
203 Before:
204
205 ```
206 use Symfony\Component\Validator\ExecutionContext;
207
208 public function validateCustomLogic(ExecutionContext $context)
209 {
210 if (/* ... */) {
211 $context->addViolationAtSubPath('myProperty', 'This value is invalid');
212 }
213 }
214 ```
215
216 After:
217
218 ```
219 use Symfony\Component\Validator\ExecutionContextInterface;
220
221 public function validateCustomLogic(ExecutionContextInterface $context)
222 {
223 if (/* ... */) {
224 $context->addViolationAt('myProperty', 'This value is invalid');
225 }
226 }
227 ```
228
229 * The methods `ExecutionContext::getCurrentClass()`, `ExecutionContext::getCurrentProperty()`
230 and `ExecutionContext::getCurrentValue()` were deprecated and will be removed
231 in Symfony 2.3. Use the methods `getClassName()`, `getPropertyName()` and
232 `getValue()` instead.
233
234 Before:
235
236 ```
237 use Symfony\Component\Validator\ExecutionContext;
238
239 public function validateCustomLogic(ExecutionContext $context)
240 {
241 $class = $context->getCurrentClass();
242 $property = $context->getCurrentProperty();
243 $value = $context->getCurrentValue();
244
245 // ...
246 }
247 ```
248
249 After:
250
251 ```
252 use Symfony\Component\Validator\ExecutionContextInterface;
253
254 public function validateCustomLogic(ExecutionContextInterface $context)
255 {
256 $class = $context->getClassName();
257 $property = $context->getPropertyName();
258 $value = $context->getValue();
259
260 // ...
261 }
262 ```
Something went wrong with that request. Please try again.