8000 [DI] Use classes from Contracts instead of the component · symfony/symfony-docs@875e13a · GitHub
[go: up one dir, main page]

Skip to content

Commit 875e13a

Browse files
committed
[DI] Use classes from Contracts instead of the component
1 parent 02904b3 commit 875e13a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

service_container/service_subscribers_locators.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ a PSR-11 ``ContainerInterface``::
7474
use App\CommandHandler\BarHandler;
7575
use App\CommandHandler\FooHandler;
7676
use Psr\Container\ContainerInterface;
77-
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
77+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
7878

7979
class CommandBus implements ServiceSubscriberInterface
8080
{
@@ -375,9 +375,8 @@ will share identical locators amongst all the services referencing them::
375375
Service Subscriber Trait
376376
------------------------
377377

378-
The :class:`Symfony\\Component\\DependencyInjection\\ServiceSubscriberTrait`
379-
provides an implementation for
380-
:class:`Symfony\\Component\\DependencyInjection\\ServiceSubscriberInterface`
378+
The :class:`Symfony\\Contracts\\Service\\ServiceSubscriberTrait` provides an
379+
implementation for :class:`Symfony\\Contracts\\Service\\ServiceSubscriberInterface`
381380
that looks through all methods in your class that have no arguments and a return
382381
type. It provides a ``ServiceLocator`` for the services of those return types.
383382
The service id is ``__METHOD__``. This allows you to add dependencies to your
@@ -387,9 +386,9 @@ services based on type-hinted helper methods::
387386
namespace App\Service;
388387

389388
use Psr\Log\LoggerInterface;
390-
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
391-
use Symfony\Component\DependencyInjection\ServiceSubscriberTrait;
392389
use Symfony\Component\Routing\RouterInterface;
390+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
391+
use Symfony\Contracts\Service\ServiceSubscriberTrait;
393392

394393
class MyService implements ServiceSubscriberInterface
395394
{
@@ -444,8 +443,8 @@ and compose your services with them::
444443
// src/Service/MyService.php
445444
namespace App\Service;
446445

447-
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
448-
use Symfony\Component\DependencyInjection\ServiceSubscriberTrait;
446+
use Symfony\Contracts\Service\ServiceSubscriberInterface;
447+
use Symfony\Contracts\Service\ServiceSubscriberTrait;
449448

450449
class MyService implements ServiceSubscriberInterface
451450
{

0 commit comments

Comments
 (0)
0