Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DoctrineBridge][Messenger] Add MessageRecordingEntity functionality #34310

Open
wants to merge 7 commits into
base: master
from

Conversation

@vudaltsov
Copy link
Contributor

vudaltsov commented Nov 10, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets n/a
License MIT
Doc PR todo

This is an alternative to #28850, thanks @Nyholm for the initial implementation and idea.
The interface I propose does not leak out the messages explicitly.

@vudaltsov

This comment has been minimized.

Copy link
Contributor Author

vudaltsov commented Nov 10, 2019

I used UOW::getIdentityMap for collecting messages because any loaded entity might issue messages.

Consider a classic DDD example. AddOrderItem command is being handled. An Aggregate Root Order is retrieved from its repository. Order::addItem() method is called and an item is added to the incapsulated Item[] collection. OrderItemAdded event is recorded. In this case the aggregate root Order has not changed from the Doctrine POV, so it's not in the $uow->getScheduledEntityUpdates() array. That's why we need to check all managed entities by iterating over the identity map.

@vudaltsov vudaltsov force-pushed the vudaltsov:message-recording-entity branch from 77cb43d to a704101 Nov 23, 2019
@vudaltsov

This comment has been minimized.

Copy link
Contributor Author

vudaltsov commented Nov 23, 2019

After a discussion with @weaverryan , I added an event hook EntityMessagePreDispatchEvent. It allows to add custom stamps to the dispatched message.

@vudaltsov

This comment has been minimized.

Copy link
Contributor Author

vudaltsov commented Nov 27, 2019

@Nyholm , @sroze , @weaverryan , looking forward to your reviews :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.