@@ -128,3 +128,67 @@ HttpFoundation
128
128
- You would need to migrate the table manually if you want to keep session information of your users.
129
129
- You could use ` PdoSessionHandler::createTable ` to initialize a correctly defined table depending on
130
130
the used database vendor.
131
+
132
+ OptionsResolver
133
+ ---------------
134
+
135
+ * The class ` OptionsResolver ` and its interface ` OptionsResolverInterface `
136
+ were deprecated. You should use the class ` Options ` together with
137
+ ` Options::resolve() ` instead.
138
+
139
+ In simple use cases, you don't need to instantiate a class anymore:
140
+
141
+ Before:
142
+
143
+ ``` php
144
+ $resolver = new OptionsResolver();
145
+ $resolver->setDefaults(array(
146
+ 'username' => 'user',
147
+ 'password' => 'pa$$word',
148
+ 'port' => 25,
149
+ ));
150
+ $resolver->setRequired(array('host'));
151
+ $resolver->setAllowedTypes(array(
152
+ 'port' => 'int',
153
+ ));
154
+
155
+ $options = $resolver->resolve($options);
156
+ ```
157
+
158
+ After:
159
+
160
+ ``` php
161
+ Options::validateRequired($options, 'host')
162
+ Options::validateTypes($options, array(
163
+ 'port' => 'int',
164
+ ));
165
+
166
+ $options = Options::resolve($options, array(
167
+ 'username' => 'user',
168
+ 'password' => 'pa$$word',
169
+ 'port' => 25,
170
+ ));
171
+ ```
172
+
173
+ When you want to distribute the configuration of the options and pass a
174
+ configuration object around, construct a new ` Options ` instance. The API
175
+ of that class is very similar to the ` OptionsResolver ` . Additionally, you
176
+ can use its ` ArrayAccess ` interface to set default option values:
177
+
178
+ ``` php
179
+ // Pass options to the constructor...
180
+ $defaults = new Options(array(
181
+ 'username' => 'user',
182
+ 'password' => 'pa$$word',
183
+ ));
184
+
185
+ // ...or using array access
186
+ $defaults['port'] = 25;
187
+
188
+ $defaults->setRequired('host');
189
+ $defaults->setAllowedTypes(array(
190
+ 'port' => 'int',
191
+ ));
192
+
193
+ $options = Options::resolve($options, $defaults);
194
+ ```
0 commit comments