10000 feature #11665 [EventDispatcher] Use the classes from Contracts inste… · symfony/symfony-docs@98dd993 · GitHub
[go: up one dir, main page]

Skip to content

Commit 98dd993

Browse files
committed
feature #11665 [EventDispatcher] Use the classes from Contracts instead of the component (javiereguiluz)
This PR was merged into the 4.2 branch. Discussion ---------- [EventDispatcher] Use the classes from Contracts instead of the component Commits ------- 7e5e969 [EventDispatcher] Use the classes from Contracts instead of the component
2 parents 311c775 + 7e5e969 commit 98dd993

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
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
{

0 commit comments

Comments
 (0)
0