phpcr-odm
phpcr-odm copied to clipboard
DocumentListeners
Doctrine ORM allows to define listeners for specific Entities (http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#entity-listeners). Is it possible to do the same thing with PHPCR-ODM?
No this isn't implemented (afaik), but would be a valid feature. So you could make a PR or change this to a feature request.
In the meantime you can always use normal event listeners and do something like:
class FoobarEventListener
{
public function preUpdate(PreUpdateEvent $event)
{
$document = $event->getObject();
if ($document instanceof MyProject\Document\User) {
// do something
}
}
Yep, it's what I was thinking to do.
When I will have some spare time I will work on this feature.
sounds great! phpcr-odm was started looking at the code of the orm around 2.1 i think, and we have not ported over all the features. some things move into doctrine commons, which help a lot as it allows to share code instead of reimplementing - but when things get too specific, that is not an option. @ocramius was doing a lot of the pushing to commons, maybe he has some input on this one?
This is something that has been completely designed/implemented by @FabioBatSilva, so better check it with him :-)
The logic was strictly coupled with the UoW IIRC