-
Notifications
You must be signed in to change notification settings - Fork 519
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
[WIP] Refactoring of event listeners(closes #8, #89, #123, #297) #617
base: master
Are you sure you want to change the base?
Conversation
d91613a
to
4f9daa1
Compare
f804e86
to
accb50f
Compare
'prePersist', | ||
'preUpdate', | ||
); | ||
return array(Events::preFlush); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this breaks for people using the ODM rather than the ORM as they won't have the constant defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you suggest: use strings or create different classes wich rely on different class contsants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use strings
*/ | ||
public function prePersist(EventArgs $event) | ||
public function preFlush(PreFlushEventArgs $event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this typehint will break as well for other Doctrine projects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove typehint or create different class for ODM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typehint using only the classes from Doctrine Common (and add instanceof checks internally if they have not settled on a common API for the preflush
event but this should also be reported to Doctrine as events have been more or less standardized in doctrine/common, but Doctrine\Common\EventArgs should extend \Doctrine\Common\Persistence\Event\ManagerEventArgs
in future versions to be consistent with other events)
preflush is not properly standardized among Doctrine projects yet (check the case of the ODM fully then btw, as this event might cause you some issues)
@stof what can you say about this PR in general? And I have some problem with Propel integration. Not sure this approach will work correctly |
{ | ||
$object = $this->adapter->getObjectFromArgs($event); | ||
$em = $event->getEntityManager(); | ||
$identityMap = $em->getUnitOfWork()->getIdentityMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal Doctrine API AFAIK. Relying on it may not be the best idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I got changed entities in other way? PreFlush
event not recieve entities
@@ -2,42 +2,40 @@ | |||
|
|||
namespace Vich\UploaderBundle\EventListener\Doctrine; | |||
|
|||
use Doctrine\Common\EventArgs; | |||
use Doctrine\ORM\Event\LifecycleEventArgs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use the doctrine/common class
@Koc can you solve conflict? And maybe adding some tests? |
branch restarted and rebased. I'm afraid that this PR breaks BC. But we can start working on 2.0 where BC-breaks are acceptable. |
Code is not tested yet, WIP.
preFlush
triggersLooks like
AdapterInterface::recomputeChangeSet
is not called anymore.