You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the dispatch 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.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
symfony-docs/components/event_dispatcher.rst
Lines 278 to 292 in b9f8400
This article specifies "the name of the event to dispatch" as an argument to the
dispatch
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.
The text was updated successfully, but these errors were encountered: