Skip to content

Commit 4f5bec9

Browse files
committed
Updates according to code updates
1 parent 750e422 commit 4f5bec9

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

service_container/service_decoration.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Control the behavior when the decorated service does not exist
317317
--------------------------------------------------------------
318318

319319
Let's imagine you have a decorator that decorates a service defined in another bundle.
320-
If for some reasons, that bundle is missing, the ``decoration_on_decorated_invalid``
320+
If for some reasons, that bundle is missing, the ``decoration_on_invalid``
321321
option will allow you to handle the lack of decorated service.
322322

323323
.. configuration-block::
@@ -330,7 +330,7 @@ option will allow you to handle the lack of decorated service.
330330
Bar:
331331
public: false
332332
decorates: Foo
333-
decoration_on_decorated_invalid: ignore
333+
decoration_on_invalid: ignore
334334
arguments: ['@Bar.inner']
335335
336336
.. code-block:: xml
@@ -345,7 +345,7 @@ option will allow you to handle the lack of decorated service.
345345
<services>
346346
<service id="Foo"/>
347347
348-
<service id="Bar" decorates="Foo" decoration-on-decorated-invalid="ignore">
348+
<service id="Bar" decorates="Foo" decoration-on-invalid="ignore">
349349
<argument type="service" id="Bar.inner"/>
350350
</service>
351351
</services>
@@ -377,14 +377,28 @@ Three different behaviors are available:
377377

378378
* ``exception``: The default behavior. When used, a ``ServiceNotFoundException``
379379
will be thrown telling that decorator's dependency is missing.
380-
* ``ignored``: Using that behavior, the container will remove either decorator
380+
* ``ignore``: Using that behavior, the container will remove either decorator
381381
and decorated services.
382-
* ``nulled``: When used, the container will keep the decorator
382+
* ``null``: When used, the container will keep the decorator
383383
service and will set the decorated one to `null`.
384384

385+
.. note::
386+
387+
If you are using yaml to describe your services, please ensure that
388+
``null`` value is wrapped with quotes. In fact in yaml, ``null`` will be interpreted
389+
as the null value and not as the null string. Therefore, the compiler will throw
390+
an ``InvalidArgumentException``
391+
392+
.. code-block:: yaml
393+
394+
Foo:
395+
decorates: Foo
396+
decoration_on_invalid: 'null'
397+
arguments: ['@Bar.inner']
398+
385399
.. tip::
386400

387-
When using ``nulled``, you may update the decorator's constructor in
401+
When using ``null``, you may update the decorator's constructor in
388402
order to make decorated dependency nullable. In this way, you will be able to
389403
check the presence of decorated service in other methods.
390404

0 commit comments

Comments
 (0)