diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 2c057067927..04430276595 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -140,6 +140,18 @@ count and iterate over the services of the locator:: The :class:`Symfony\\Contracts\\Service\\ServiceCollectionInterface` was introduced in Symfony 7.1. +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 ------------------ 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