@@ -379,39 +379,37 @@ Three different behaviors are available:
379
379
When using ``null ``, you may have to update the decorator constructor in
380
380
order to make decorated dependency nullable.
381
381
382
- .. configuration -block ::
382
+ .. code -block :: yaml
383
383
384
- .. code-block :: yaml
384
+ App\Service\DecoratorService :
385
+ decorates : Acme\OptionalBundle\Service\OptionalService
386
+ decoration_on_invalid : null
387
+ arguments : ['@App\Service\DecoratorService.inner']
385
388
386
- App\Service\DecoratorService :
387
- decorates : Acme\OptionalBundle\Service\OptionalService
388
- decoration_on_invalid : null
389
- arguments : ['@App\Service\DecoratorService.inner']
389
+ .. code-block :: php
390
390
391
- .. code-block :: php
391
+ namespace App\Service;
392
392
393
- namespace App\ Service;
393
+ use Acme\OptionalBundle\ Service\OptionalService ;
394
394
395
- use Acme\OptionalBundle\Service\OptionalService;
395
+ class DecoratorService
396
+ {
397
+ private $decorated;
396
398
397
- class DecoratorService
399
+ public function __construct(?OptionalService $decorated)
398
400
{
399
- private $decorated;
401
+ $this->decorated = $decorated;
402
+ }
400
403
401
- public function __construct(?OptionalService $decorated)
402
- {
403
- $this->decorated = $decorated;
404
+ public function tellInterestingStuff(): string
405
+ {
406
+ if (!$this->decorated) {
407
+ return 'Just one interesting thing';
404
408
}
405
409
406
- public function tellInterestingStuff(): string
407
- {
408
- if (!$this->decorated) {
409
- return 'Just one interesting thing';
410
- }
411
-
412
- return $this->decorated->tellInterestingStuff().' + one more interesting thing';
413
- }
410
+ return $this->decorated->tellInterestingStuff().' + one more interesting thing';
414
411
}
412
+ }
415
413
416
414
.. note ::
417
415
0 commit comments