headsnet / domain-events-bundle

DDD Domain events for Symfony
MIT License
39 stars 4 forks source link

Question: Effect of two lines in \Headsnet\DomainEventsBundle\Doctrine\DoctrineEventStore::append #7

Closed wazum closed 4 years ago

wazum commented 4 years ago

https://github.com/headsnet/domain-events-bundle/blob/6b4e4b76d24c81493228d3eaf36618112f4598ae/src/Doctrine/DoctrineEventStore.php#L71-L72

What do these lines do exactly? \Doctrine\ORM\UnitOfWork::computeChangeSet is marked as @internal

benr77 commented 4 years ago

Good question. I'm not 100% sure any more as it was 1 year ago and my commit message is not helpful!

It is something to do with flushing the changes, as you cannot call flush() directly in the Doctrine lifecycle event listeners.

I also wonder if it might be related to running bin/console messenger:consume and processing multiple requests inside a single process - i.e. to reset Doctrine...

Either way you are right it is marked as @internal so clarifying its purpose and/or replacing with a better alternative is needed.

wazum commented 4 years ago

I read more about the details of these methods and @internal ("don't call from the outside") includes lifecycle events like 'onFlush' we use here, so that's the correct and only way to achieve this.

benr77 commented 4 years ago

Ok great thanks for the update!