@@ -96,6 +96,7 @@ is thrown if an unknown option is passed::
96
96
The rest of your code can now access the values of the options without
97
97
boilerplate code::
98
98
99
+ // ...
99
100
class Mailer
100
101
{
101
102
// ...
@@ -117,8 +118,7 @@ If an option must be set by the caller, pass that option to
117
118
:method: `Symfony\\ Component\\ OptionsResolver\\ Options::validateRequired `.
118
119
For example, let's make the ``host `` option required::
119
120
120
- use Symfony\Component\OptionsResolver\Options;
121
-
121
+ // ...
122
122
class Mailer
123
123
{
124
124
// ...
@@ -160,9 +160,8 @@ Type Validation
160
160
You can run additional checks on the options to make sure they were passed
161
161
correctly. To validate the types of the options, call
162
162
:method: `Symfony\\ Component\\ OptionsResolver\\ Options::validateTypes `::
163
-
164
- use Symfony\Component\OptionsResolver\Options;
165
-
163
+
164
+ // ...
166
165
class Mailer
167
166
{
168
167
// ...
@@ -206,8 +205,7 @@ one of ``sendmail``, ``mail`` and ``smtp``. Use the method
206
205
:method: `Symfony\\ Component\\ OptionsResolver\\ Options::validateValues ` to verify
207
206
that the passed option contains one of these values::
208
207
209
- use Symfony\Component\OptionsResolver\Options;
210
-
208
+ // ...
211
209
class Mailer
212
210
{
213
211
// ...
@@ -256,8 +254,7 @@ You can implement this feature by passing a closure as default value of the
256
254
``port `` option. The closure receives the options as argument. Based on these
257
255
options, you can return the desired default value::
258
256
259
- use Symfony\Component\OptionsResolver\Options;
260
-
257
+ // ...
261
258
class Mailer
262
259
{
263
260
// ...
@@ -305,8 +302,7 @@ If you have a large list of options, the option processing code can take up a
305
302
lot of space of your method. To make your code easier to read and maintain, it
306
303
is a good practice to put the option definitions into static class properties::
307
304
308
- use Symfony\Component\OptionsResolver\Options;
309
-
305
+ // ...
310
306
class Mailer
311
307
{
312
308
private static $defaultOptions = array(
@@ -382,7 +378,7 @@ configuration object to resolve the options.
382
378
The following code demonstrates how to write our previous ``Mailer `` class with
383
379
an :class: `Symfony\\ Component\\ OptionsResolver\\ OptionsConfig ` object::
384
380
385
- use Symfony\Component\OptionsResolver\Options;
381
+ // ...
386
382
use Symfony\Component\OptionsResolver\OptionsConfig;
387
383
388
384
class Mailer
@@ -431,9 +427,7 @@ the :class:`Symfony\\Component\\OptionsResolver\\OptionsConfig` instance.
431
427
Nevertheless, this design also has a benefit: We can extend the ``Mailer ``
432
428
class and adjust the options of the parent class in the subclass::
433
429
434
- use Symfony\Component\OptionsResolver\Options;
435
- use Symfony\Component\OptionsResolver\OptionsConfig;
436
-
430
+ // ...
437
431
class GoogleMailer extends Mailer
438
432
{
439
433
protected function configureOptions(OptionsConfig $config)
@@ -476,9 +470,7 @@ however, *no default value* will be added to the options array. Pass the names
476
470
of the optional options to
477
471
:method: `Symfony\\ Component\\ OptionsResolver\\ OptionsConfig::setOptional `::
478
472
479
- use Symfony\Component\OptionsResolver\Options;
480
- use Symfony\Component\OptionsResolver\OptionsConfig;
481
-
473
+ // ...
482
474
class Mailer
483
475
{
484
476
// ...
@@ -493,6 +485,7 @@ of the optional options to
493
485
This is useful if you need to know whether an option was explicitly passed. If
494
486
not, it will be missing from the options array::
495
487
488
+ // ...
496
489
class Mailer
497
490
{
498
491
// ...
@@ -523,8 +516,7 @@ not, it will be missing from the options array::
523
516
the options before calling
524
517
:method: `Symfony\\ Component\\ OptionsResolver\\ Options::resolve `::
525
518
526
- use Symfony\Component\OptionsResolver\Options;
527
-
519
+ // ...
528
520
class Mailer
529
521
{
530
522
// ...
@@ -557,9 +549,7 @@ again. When using a closure as the new value it is passed 2 arguments:
557
549
558
550
.. code-block :: php
559
551
560
- use Symfony\Component\OptionsResolver\Options;
561
- use Symfony\Component\OptionsResolver\OptionsConfig;
562
-
552
+ // ...
563
553
class Mailer
564
554
{
565
555
// ...
@@ -592,9 +582,7 @@ again. When using a closure as the new value it is passed 2 arguments:
592
582
to improve performance. This means that the previous default value is not
593
583
available when overwriting with another closure::
594
584
595
- use Symfony\Component\OptionsResolver\Options;
596
- use Symfony\Component\OptionsResolver\OptionsConfig;
597
-
585
+ // ...
598
586
class Mailer
599
587
{
600
588
// ...
@@ -635,9 +623,7 @@ you can write normalizers. Normalizers are executed after all options were
635
623
processed. You can configure these normalizers by calling
636
624
:method: `Symfony\\ Components\\ OptionsResolver\\ OptionsConfig::setNormalizers `::
637
625
638
- use Symfony\Component\OptionsResolver\Options;
639
- use Symfony\Component\OptionsResolver\OptionsConfig;
640
-
626
+ // ...
641
627
class Mailer
642
628
{
643
629
// ...
@@ -661,9 +647,7 @@ The normalizer receives the actual ``$value`` and returns the normalized form.
661
647
You see that the closure also takes an ``$options `` parameter. This is useful
662
648
if you need to use other options for the normalization::
663
649
664
- use Symfony\Component\OptionsResolver\Options;
665
- use Symfony\Component\OptionsResolver\OptionsConfig;
666
-
650
+ // ...
667
651
class Mailer
668
652
{
669
653
// ...
@@ -693,8 +677,7 @@ if you need to use other options for the normalization::
693
677
object, perform normalization after the call to
694
678
:method: `Symfony\\ Component\\ OptionsResolver\\ Options::resolve `::
695
679
696
- use Symfony\Component\OptionsResolver\Options;
697
-
680
+ // ...
698
681
class Mailer
699
682
{
700
683
// ...
0 commit comments