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

domain event on removal not working with CollectsEventsFromAllEntitiesManagedByUnitOfWork #10

Open
kermorgant opened this issue Apr 16, 2018 · 2 comments

Comments

@kermorgant
Copy link

kermorgant commented Apr 16, 2018

Hi,

First, thanks for the work on this bundle. I've been picking some ideas from ddd and this bundle has been very helpful !

So, I just wanted to issue a domain event after removing an entity and noticed it did not work if I had

tactician_domain_event:
    collect_from_all_managed_entities: true

Seems like the removed entity does not figure in the unit of work on the postFlush method.

On the other hand, after changing the collect_from_all_managed_entities configuration to true false (edit), the event was dispatched correctly.

@maks-rafalko
Copy link
Owner

Hi, thanks for opening this issue!

noticed it did not work if I had

tactician_domain_event:
    collect_from_all_managed_entities: true

On the other hand, after changing the collect_from_all_managed_entities configuration to true, the event was dispatched correctly.

  1. I didn't get in which case it does not collect events after removing entities, with true or false for collect_from_all_managed_entities?
  2. Do you have any relations between entities? Could you please describe your object graph a little bit?

@kermorgant
Copy link
Author

Sorry for the typo, issue happened when value was set to true (see edit above).

Entity is "Article" and removal happens when calling remove method of ArticleRepository

    public function remove(Article $article)
    {
        $article->prepareForRemoval();
        $this->em->remove($article);
    }

And from Article :

    public function prepareForRemoval()
    {
        $this->record(new ArticleWasRemoved($this->id));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants