diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 397e7141bf4..ec57eb8f12b 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -570,6 +570,23 @@ Now you can inject the service locator in any other services: .. configuration-block:: + .. code-block:: php-attributes + + // src/CommandBus.php + namespace App; + + use Psr\Container\ContainerInterface; + use Symfony\Component\DependencyInjection\Attribute\Autowire; + + class CommandBus + { + public function __construct( + #[Autowire(service: 'app.command_handler_locator')] + private ContainerInterface $locator, + ) { + } + } + .. code-block:: yaml # config/services.yaml