Skip to content

HTTPS clone URL

Subversion checkout URL

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