8000 [OptionsResolver] Merged Options and OptionsConfig and restored old O… · symfony/symfony@fdaae2a · GitHub
[go: up one dir, main page]

Skip to content

Commit fdaae2a

Browse files
committed
[OptionsResolver] Merged Options and OptionsConfig and restored old OptionsResolver class
1 parent 966c586 commit fdaae2a

File tree

9 files changed

+2142
-1354
lines changed

9 files changed

+2142
-1354
lines changed

UPGRADE-2.6.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,47 @@ HttpFoundation
128128
- You would need to migrate the table manually if you want to keep session information of your users.
129129
- You could use `PdoSessionHandler::createTable` to initialize a correctly defined table depending on
130130
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+
Before:
140+
141+
```php
142+
$resolver = new OptionsResolver();
143+
$resolver->setDefaults(array(
144+
'username' => 'user',
145+
'password' => 'pa$$word',
146+
'port' => 25,
147+
));
148+
$resolver->setRequired(array('host'));
149+
$resolver->setAllowedTypes(array(
150+
'port' => 'int',
151+
));
152+
153+
$options = $resolver->resolve($options);
154+
```
155+
156+
After:
157+
158+
```php
< 8000 /code>
159+
// Pass options to the constructor...
160+
$options = new Options(array(
161+
'username' => 'user',
162+
'password' => 'pa$$word',
163+
));
164+
165+
// ...or using array access
166+
$options['port'] = 25;
167+
168+
$options->setRequired('host');
169+
$options->setAllowedTypes(array(
170+
'port' => 'int',
171+
));
172+
173+
$resolvedOptions = $options->resolve($userOptions);
174+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CHANGELOG
2+
=========
3+
4+
2.6.0
5+
-----
6+
7+
* added Options::resolve()
8+
* added Options::merge()
9+
* added Options::setNormalizers()
10+
* added Options::setRequired()
11+
* added Options::isRequired()
12+
* added Options::getRequiredOptions()
13+
* added Options::isMissing()
14+
* added Options::getMissingOptions()
15+
* added Options::setDefined()
16+
* added Options::isDefined()
17+
* added Options::getDefinedOptions()
18+
* added Options::setAllowedValues()
19+
* added Options::addAllowedValues()
20+
* added Options::setAllowedTypes()
21+
* added Options::addAllowedTypes()
22+
* deprecated Options::overload() in favor of set()
23+
* deprecated OptionsResolver
24+
* deprecated OptionsResolverInterface
25+
* [BC BREAK] Options::get() can only be used within lazy option/normalizer
26+
closures now
27+
* [BC BREAK] removed Traversable interface from Options since using within
28+
lazy option/normalizer closures resulted in exceptions
29+
* [BC BREAK] removed Options::all() since using within lazy option/normalizer
30+
closures resulted in exceptions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\OptionsResolver\Exception;
13+
14+
/**
15+
* Thrown when trying to read an option outside of {@link Options::resolve()}.
16+
*
17+
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*/
19+
class ReadException extends \RuntimeException implements ExceptionInterface
20+
{
21+
}

0 commit comments

Comments
 (0)
0