/** * {@inheritDoc} */ public function subscribe(EventListenerInterface $eventListener) { parent::subscribe($eventListener); if ($eventListener instanceof ReplayAwareInterface) { $this->replayAwareEventListeners[] = $eventListener; } }
public function eventHandling() { // Create the event bus and subscribe the created event listener $eventBus = new SimpleEventBus(); $eventListener = new MyEventListener(); $eventBus->subscribe($eventListener); // Create a domain event stream to publish $metadata = new Metadata(['source' => 'example']); $domainMessage = DomainMessage::recordNow(42, 1, $metadata, new stdClass()); $domainEventStream = new DomainEventStream([$domainMessage]); // Publish the message, and get output from the event handler \o/ $eventBus->publish($domainEventStream); }