Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 900 Bytes

cookbooks.md

File metadata and controls

32 lines (23 loc) · 900 Bytes

Cookbooks

This section is about some things you can do while using this component.

  1. Use events from another component in the domain dispatcher

Support other events

In some special cases you may have to handle some other events. For example the workflow of Symfony dispatch events specific to this composant. You can transform these events by redefining the dispatcher and transform the event:

<?php

class WorkflowDomainEventDispatcher extends DomainEventDispatcher
{
    public function dispatch(Event $event, $eventName = null)
    {
        if ($event instanceof \Symfony\Component\Workflow\Event\Event) {
            $event = new DomainEvent($event->getSubject(), [], $event);
        }

        return parent::dispatch($event, $eventName);
    }
}

You can do this because the domain event support embedded events. 👍