Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.2k
Open
Description
symfony-docs/components/event_dispatcher.rst
Lines 278 to 292 inb9f8400
The:method:`Symfony\\Component\\EventDispatcher\\EventDispatcher::dispatch` | |
method notifies all listeners of the given event. It takes two arguments: | |
the ``Event`` instance to pass to each listener of that event and the name | |
of the event to dispatch:: | |
use Acme\Store\Event\OrderPlacedEvent; | |
use Acme\Store\Order; | |
// the order is somehow created or retrieved | |
$order = new Order(); | |
// ... | |
// creates the OrderPlacedEvent and dispatches it | |
$event = new OrderPlacedEvent($order); | |
$dispatcher->dispatch($event); |
This article specifies "the name of the event to dispatch" as an argument to thedispatch
method, immediately followed by an example that never uses said argument.
There's no explanation I can find about why this argument is optional and what difference it makes if we can have an example without it. Granted there's a note below this block that says OrderPlacedEvent listeners will receive the OrderPlacedEvent. But that would seem to be self-evident and unrelated to the name of the event.
This needs to be clarified.
Metadata
Metadata
Assignees
Labels
No labels