-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from biig-io/feature/events-in-domainevents
Support for embedded events in DomainEvents
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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) | ||
|
||
|
||
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 | ||
<?php | ||
|
||
class WorkflowDomainEventDispatcher extends DomainEventDispatcher | ||
{ | ||
public function dispatch($eventName, Event $event = null) | ||
{ | ||
if ($event instanceof \Symfony\Component\Workflow\Event\Event) { | ||
$event = new DomainEvent($event->getSubject(), [], $event); | ||
} | ||
|
||
return parent::dispatch($eventName, $event); | ||
} | ||
} | ||
``` | ||
|
||
You can do this because the domain event support embedded events. 👍 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters