Skip to content

[EventDispatcher] Use the classes from Contracts instead of the component #11665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions components/event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Events

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

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

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

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

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class AcmeListener
{
Expand Down Expand Up @@ -252,7 +252,7 @@ order. Start by creating this custom event class and documenting it::
namespace Acme\Store\Event;

use Acme\Store\Order;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

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

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

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

// ...
Expand Down Expand Up @@ -450,7 +450,7 @@ Dispatcher Shortcuts
~~~~~~~~~~~~~~~~~~~~

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

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

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class Foo
{
Expand Down
4 changes: 2 additions & 2 deletions components/event_dispatcher/generic_event.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
The Generic Event Object
========================

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

:class:`Symfony\\Component\\EventDispatcher\\GenericEvent` adds some more
methods in addition to the base class
:class:`Symfony\\Component\\EventDispatcher\\Event`
:class:`Symfony\\Contracts\\EventDispatcher\\Event`

* :method:`Symfony\\Component\\EventDispatcher\\GenericEvent::__construct`:
Constructor takes the event subject and any arguments;
Expand Down
4 changes: 2 additions & 2 deletions event_dispatcher/method_behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ events. For example, ``BeforeSendMailEvent`` might look like this::
// src/Event/BeforeSendMailEvent.php
namespace App\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class BeforeSendMailEvent extends Event
{
Expand Down Expand Up @@ -83,7 +83,7 @@ And the ``AfterSendMailEvent`` even like this::
// src/Event/AfterSendMailEvent.php
namespace App\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class AfterSendMailEvent extends Event
{
Expand Down