Skip to content

Fix: remove decoration-on-invalid unneeded configuration block #13160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions service_container/service_decoration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down