From 10fd2ab4886d592baf2cc24f0580afa2f8fa1c76 Mon Sep 17 00:00:00 2001 From: Adrien Roches Date: Wed, 14 May 2025 11:50:36 +0200 Subject: [PATCH 1/4] Add note about not using autoconfigure --- service_container/service_subscribers_locators.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 2c057067927..a351b3f23da 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -140,6 +140,11 @@ count and iterate over the services of the locator:: The :class:`Symfony\\Contracts\\Service\\ServiceCollectionInterface` was introduced in Symfony 7.1. +Without autoconfiguration +~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you are not using autoconfiguration you need to require either ``Psr\Container\ContainerInterface`` or ``Symfony\Contracts\Service\ServiceProviderInterface`` as a ``__construct`` argument or as a method call like ``setContainer(Psr\Container\ContainerInterface $container)``. + Including Services ------------------ From 46b2fe63b6912ed3cac4625a7829f5f168631055 Mon Sep 17 00:00:00 2001 From: Adrien Roches Date: Thu, 15 May 2025 12:49:19 +0200 Subject: [PATCH 2/4] Fix autoconfigure to autowire --- service_container/service_subscribers_locators.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index a351b3f23da..9c928e425e5 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -140,10 +140,10 @@ count and iterate over the services of the locator:: The :class:`Symfony\\Contracts\\Service\\ServiceCollectionInterface` was introduced in Symfony 7.1. -Without autoconfiguration -~~~~~~~~~~~~~~~~~~~~~~~~~ +Without autowire +~~~~~~~~~~~~~~~~ -If you are not using autoconfiguration you need to require either ``Psr\Container\ContainerInterface`` or ``Symfony\Contracts\Service\ServiceProviderInterface`` as a ``__construct`` argument or as a method call like ``setContainer(Psr\Container\ContainerInterface $container)``. +If you are not using autowire you need to require either ``Psr\Container\ContainerInterface`` or ``Symfony\Contracts\Service\ServiceProviderInterface`` as a ``__construct`` argument or as a method call like ``setContainer(Psr\Container\ContainerInterface $container)``. Including Services ------------------ From b4af396fecd4de36612cd9b04c4aa3292b4b3eee Mon Sep 17 00:00:00 2001 From: Adrien Roches Date: Thu, 15 May 2025 14:12:06 +0200 Subject: [PATCH 3/4] Add example --- service_container/service_subscribers_locators.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 9c928e425e5..3460710a4b4 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -145,6 +145,12 @@ Without autowire If you are not using autowire you need to require either ``Psr\Container\ContainerInterface`` or ``Symfony\Contracts\Service\ServiceProviderInterface`` as a ``__construct`` argument or as a method call like ``setContainer(Psr\Container\ContainerInterface $container)``. +.. code-block:: diff + $services->set('my_service', SomeClass::class) + + ->call('setContainer', [service(ContainerInterface::class)]) + + ->tag('container.service_subscriber') + ; + Including Services ------------------ From 957874ea08a3d14ac68b03c569404b22e53f0d72 Mon Sep 17 00:00:00 2001 From: Adrien Roches Date: Thu, 15 May 2025 14:15:37 +0200 Subject: [PATCH 4/4] Add missing empty line --- service_container/service_subscribers_locators.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 3460710a4b4..04430276595 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -146,6 +146,7 @@ Without autowire If you are not using autowire you need to require either ``Psr\Container\ContainerInterface`` or ``Symfony\Contracts\Service\ServiceProviderInterface`` as a ``__construct`` argument or as a method call like ``setContainer(Psr\Container\ContainerInterface $container)``. .. code-block:: diff + $services->set('my_service', SomeClass::class) + ->call('setContainer', [service(ContainerInterface::class)]) + ->tag('container.service_subscriber') pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy