Skip to content

Commit 27fc5dc

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: [EventDispatcher] Use the classes from Contracts instead of the component [DI] Use classes from Contracts instead of the component
2 parents 0bbb10c + f5d4a76 commit 27fc5dc

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

components/event_dispatcher.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Events
7272

7373
When an event is dispatched, it's identified by a unique name (e.g.
7474
``kernel.response``), which any number of listeners might be listening to.
75-
An :class:`Symfony\\Component\\EventDispatcher\\Event` instance is also
75+
An :class:`Symfony\\Contracts\\EventDispatcher\\Event` instance is also
7676
created and passed to all of the listeners. As you'll see later, the ``Event``
7777
object itself often contains data about the event being dispatched.
7878

@@ -161,7 +161,7 @@ The ``addListener()`` method takes up to three arguments:
161161
So far, you've seen how PHP objects can be registered as listeners.
162162
You can also register PHP `Closures`_ as event listeners::
163163

164-
use Symfony\Component\EventDispatcher\Event;
164+
use Symfony\Contracts\EventDispatcher\Event;
165165

166166
$dispatcher->addListener('acme.foo.action', function (Event $event) {
167167
// will be executed when the acme.foo.action event is dispatched
@@ -172,7 +172,7 @@ is notified. In the above example, when the ``acme.foo.action`` event is dispatc
172172
the dispatcher calls the ``AcmeListener::onFooAction()`` method and passes
173173
the ``Event`` object as the single argument::
174174

175-
use Symfony\Component\EventDispatcher\Event;
175+
use Symfony\Contracts\EventDispatcher\Event;
176176

177177
class AcmeListener
178178
{
@@ -252,7 +252,7 @@ order. Start by creating this custom event class and documenting it::
252252
namespace Acme\Store\Event;
253253

254254
use Acme\Store\Order;
255-
use Symfony\Component\EventDispatcher\Event;
255+
use Symfony\Contracts\EventDispatcher\Event;
256256

257257
/**
258258
* The order.placed event is dispatched each time an order is created
@@ -281,7 +281,7 @@ Each listener now has access to the order via the ``getOrder()`` method.
281281

282282
If you don't need to pass any additional data to the event listeners, you
283283
can also use the default
284-
:class:`Symfony\\Component\\EventDispatcher\\Event` class. In such case,
284+
:class:`Symfony\\Contracts\\EventDispatcher\\Event` class. In such case,
285285
you can document the event and its name in a generic ``StoreEvents`` class,
286286
similar to the :class:`Symfony\\Component\\HttpKernel\\KernelEvents`
287287
class.
@@ -419,7 +419,7 @@ Now, any listeners to ``order.placed`` that have not yet been called will
419419
*not* be called.
420420

421421
It is possible to detect if an event was stopped by using the
422-
:method:`Symfony\\Component\\EventDispatcher\\Event::isPropagationStopped`
422+
:method:`Symfony\\Contracts\\EventDispatcher\\Event::isPropagationStopped`
423423
method which returns a boolean value::
424424

425425
// ...
@@ -450,7 +450,7 @@ Dispatcher Shortcuts
450450
~~~~~~~~~~~~~~~~~~~~
451451

452452
If you do not need a custom event object, you can rely on a plain
453-
:class:`Symfony\\Component\\EventDispatcher\\Event` object. You do not even
453+
:class:`Symfony\\Contracts\\EventDispatcher\\Event` object. You do not even
454454
need to pass this to the dispatcher as it will create one by default unless you
455455
specifically pass one::
456456

@@ -482,8 +482,8 @@ Event Name Introspection
482482
The ``EventDispatcher`` instance, as well as the name of the event that
483483
is dispatched, are passed as arguments to the listener::
484484

485-
use Symfony\Component\EventDispatcher\Event;
486-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
485+
use Symfony\Contracts\EventDispatcher\Event;
486+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
487487

488488
class Foo
489489
{

components/event_dispatcher/generic_event.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
The Generic Event Object
55
========================
66

7-
The base :class:`Symfony\\Component\\EventDispatcher\\Event` class provided
7+
The base :class:`Symfony\\Contracts\\EventDispatcher\\Event` class provided
88
by the EventDispatcher component is deliberately sparse to allow the creation
99
of API specific event objects by inheritance using OOP. This allows for
1010
elegant and readable code in complex applications.
@@ -18,7 +18,7 @@ arguments.
1818

1919
:class:`Symfony\\Component\\EventDispatcher\\GenericEvent` adds some more
2020
methods in addition to the base class
21-
:class:`Symfony\\Component\\EventDispatcher\\Event`
21+
:class:`Symfony\\Contracts\\EventDispatcher\\Event`
2222

2323
* :method:`Symfony\\Component\\EventDispatcher\\GenericEvent::__construct`:
2424
Constructor takes the event subject and any arguments;

event_dispatcher/method_behavior.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ events. For example, ``BeforeSendMailEvent`` might look like this::
4444
// src/Event/BeforeSendMailEvent.php
4545
namespace App\Event;
4646

47-
use Symfony\Component\EventDispatcher\Event;
47+
use Symfony\Contracts\EventDispatcher\Event;
4848

4949
class BeforeSendMailEvent extends Event
5050
{
@@ -83,7 +83,7 @@ And the ``AfterSendMailEvent`` even like this::
8383
// src/Event/AfterSendMailEvent.php
8484
namespace App\Event;
8585

86-
use Symfony\Component\EventDispatcher\Event;
86+
use Symfony\Contracts\EventDispatcher\Event;
8787

8888
class AfterSendMailEvent extends Event
8989
{

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)