From df13b3021fe36752bd40bbd773fa00ca037e1a26 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 24 Apr 2017 15:28:59 +0200 Subject: [PATCH] Added a note about ignoring invalid reference arguments in colleciton arguments --- service_container/optional_dependencies.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service_container/optional_dependencies.rst b/service_container/optional_dependencies.rst index 5bc9e9b2ec3..89ff4fd8286 100644 --- a/service_container/optional_dependencies.rst +++ b/service_container/optional_dependencies.rst @@ -121,6 +121,12 @@ call if the service exists and remove the method call if it does not: )) ; +.. note:: + + If the argument to the method call is a collection of arguments and any of + them is missing, those elements are removed but the method call is still + made with the remaining elements of the collection. + In YAML, the special ``@?`` syntax tells the service container that the dependency is optional. Of course, the ``NewsletterManager`` must also be rewritten by adding a ``setMailer()`` method::