@@ -317,7 +317,7 @@ Control the behavior when the decorated service does not exist
317
317
--------------------------------------------------------------
318
318
319
319
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 ``
321
321
option will allow you to handle the lack of decorated service.
322
322
323
323
.. configuration-block ::
@@ -330,7 +330,7 @@ option will allow you to handle the lack of decorated service.
330
330
Bar :
331
331
public : false
332
332
decorates : Foo
333
- decoration_on_decorated_invalid : ignore
333
+ decoration_on_invalid : ignore
334
334
arguments : ['@Bar.inner']
335
335
336
336
.. code-block :: xml
@@ -345,7 +345,7 @@ option will allow you to handle the lack of decorated service.
345
345
<services >
346
346
<service id =" Foo" />
347
347
348
- <service id =" Bar" decorates =" Foo" decoration-on-decorated- invalid =" ignore" >
348
+ <service id =" Bar" decorates =" Foo" decoration-on-invalid =" ignore" >
349
349
<argument type =" service" id =" Bar.inner" />
350
350
</service >
351
351
</services >
@@ -377,14 +377,28 @@ Three different behaviors are available:
377
377
378
378
* ``exception ``: The default behavior. When used, a ``ServiceNotFoundException ``
379
379
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
381
381
and decorated services.
382
- * ``nulled ``: When used, the container will keep the decorator
382
+ * ``null ``: When used, the container will keep the decorator
383
383
service and will set the decorated one to `null `.
384
384
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
+
385
399
.. tip ::
386
400
387
- When using ``nulled ``, you may update the decorator's constructor in
401
+ When using ``null ``, you may update the decorator's constructor in
388
402
order to make decorated dependency nullable. In this way, you will be able to
389
403
check the presence of decorated service in other methods.
390
404
0 commit comments