4. “...the foundation of the Symfony
full-stack framework, but they can
also be used standalone even if you
don't use the framework...”
symfony.com/components
18. namespace AcmeStoreBundle;
final class StoreEvents
{
/**
* The store.order event is thrown each time an order is created
* in the system.
*/
const STORE_ORDER = 'store.order';
}
32. // event name only
$dispatcher->dispatch('store.order');
// create the StoreOrderEvent and dispatch it
$event = new StoreOrderEvent($order);
$dispatcher->dispatch(StoreEvents::STORE_ORDER, $event);
33. $a = $dispatcher->dispatch('store.event', $b);
$a === $b; // true
// returns the dispatcher created event
$dispatcher->dispatch('foo.event')->isPropagationStopped()
47. // Event name and the dispatcher passed to listener
public function onStoreOrder(
Event $event,
$eventName,
EventDispatcherInterface $eventDispatcher
)