From bc5ef854319aa6d68a0c8d2bcb545de033c6dcda Mon Sep 17 00:00:00 2001 From: Tim Goudriaan Date: Mon, 24 Sep 2018 21:09:52 +0200 Subject: [PATCH 1/2] [DependencyInjection] Add documentation for service locator changes --- .../service_subscribers_locators.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 150f9bef638..20237dd4566 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -243,8 +243,9 @@ Defining a Service Locator -------------------------- To manually define a service locator, create a new service definition and add -the ``container.service_locator`` tag to it. Use its ``arguments`` option to -include as many services as needed in it. +the ``container.service_locator`` tag to it. Use the first argument of the +service definition to pass a collection of services to the service locator. If +there is no id specified for the service it will inherit its external id. .. configuration-block:: @@ -306,6 +307,16 @@ include as many services as needed in it. // ->addTag('container.service_locator') ; +.. versionadded:: 4.1 + The service locator autoconfiguration was introduced in Symfony 4.1. In + previous Symfony versions you always needed to add the + ``container.service_locator`` tag explicitly. + +.. versionadded:: 4.2 + + The ability to add services without specifying an id was introduced in + Symfony 4.2. + .. note:: The services defined in the service locator argument must include keys, From 8d8c65e7ceb64e6a913e17a45175719d4b65e439 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 8 Oct 2018 12:32:11 +0200 Subject: [PATCH 2/2] Reword --- .../service_subscribers_locators.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 20237dd4566..239209210ac 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -244,8 +244,7 @@ Defining a Service Locator To manually define a service locator, create a new service definition and add the ``container.service_locator`` tag to it. Use the first argument of the -service definition to pass a collection of services to the service locator. If -there is no id specified for the service it will inherit its external id. +service definition to pass a collection of services to the service locator: .. configuration-block:: @@ -259,6 +258,9 @@ there is no id specified for the service it will inherit its external id. - App\FooCommand: '@app.command_handler.foo' App\BarCommand: '@app.command_handler.bar' + # if the element has no key, the ID of the original service is used + '@app.command_handler.baz' + # if you are not using the default service autoconfiguration, # add the following tag to the service definition: # tags: ['container.service_locator'] @@ -275,8 +277,10 @@ there is no id specified for the service it will inherit its external id. - - + + + +