From 463d1e3c1a7cc354bcb0f29114c5bcd254213fa8 Mon Sep 17 00:00:00 2001 From: Mathias Arlaud Date: Mon, 17 Feb 2020 10:11:31 +0100 Subject: [PATCH] Remove configuration block --- service_container/service_decoration.rst | 41 +++++++++--------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst index dfc13c2b699..56a1ec65789 100644 --- a/service_container/service_decoration.rst +++ b/service_container/service_decoration.rst @@ -377,41 +377,30 @@ Three different behaviors are available: .. caution:: When using ``null``, you may have to update the decorator constructor in - order to make decorated dependency nullable. + order to make decorated dependency nullable:: - .. configuration-block:: - - .. code-block:: yaml - - App\Service\DecoratorService: - decorates: Acme\OptionalBundle\Service\OptionalService - decoration_on_invalid: null - arguments: ['@App\Service\DecoratorService.inner'] - - .. code-block:: php + namespace App\Service; - namespace App\Service; + use Acme\OptionalBundle\Service\OptionalService; - use Acme\OptionalBundle\Service\OptionalService; + class DecoratorService + { + private $decorated; - class DecoratorService + public function __construct(?OptionalService $decorated) { - private $decorated; + $this->decorated = $decorated; + } - public function __construct(?OptionalService $decorated) - { - $this->decorated = $decorated; + public function tellInterestingStuff(): string + { + if (!$this->decorated) { + return 'Just one interesting thing'; } - public function tellInterestingStuff(): string - { - if (!$this->decorated) { - return 'Just one interesting thing'; - } - - return $this->decorated->tellInterestingStuff().' + one more interesting thing'; - } + return $this->decorated->tellInterestingStuff().' + one more interesting thing'; } + } .. note::