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

preFlush: PreFlushEventArgs should contain the entity being flushed #6046

Closed
andreas-glaser opened this issue Sep 21, 2016 · 4 comments
Closed
Assignees

Comments

@andreas-glaser
Copy link

I'm working on a small library and found myself in need of the entity that is being flushed within the preFlush event. This should be part of the PreFlushEventArgs object in my opinion.

<?php
// UnitOfWork.php 
// ...
public function commit($entity = null)
    {
        // Raise preFlush
        if ($this->evm->hasListeners(Events::preFlush)) {
            $this->evm->dispatchEvent(Events::preFlush, new PreFlushEventArgs($this->em, $entity));
        }
// ...

Any thoughts on this?

@coudenysj
Copy link
Contributor

The preFlush event occurs before the changes are computed in the UnitOfWork. At this point, the UnitOfWork is not aware which entities should be flushed (the $entity parameter is optional).

Cant you use the onFlush event?

@andreas-glaser
Copy link
Author

andreas-glaser commented Sep 27, 2016

Yes it does occur before but the commit function "knows" whether a specific or any altered entity should be updated. Unfortunately i cannot use the onFlush event as my library does some preprocessing before any change-sets are calculated.

It just seems that the preFlush event should be aware of the $entity argument being passed into the method. I mean without it there is very little use for the event... or at least I cannot think of any uses.

https://github.com/andreas-glaser/dc-event-bundle/tree/1.1

@linaori
Copy link

linaori commented Oct 2, 2016

see #5848

@Ocramius
Copy link
Member

Ocramius commented Oct 2, 2016

Closing as duplicate.

@Ocramius Ocramius closed this as completed Oct 2, 2016
@Ocramius Ocramius self-assigned this Oct 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants