siestacat / doctrine-odm-event-listener
Doctrine ODM event listener
1.0.1
2024-01-04 12:26 UTC
Requires
- php: ^8.1
- doctrine/mongodb-odm: ^2.3
- symfony/config: ^6.3 || ^7.0
- symfony/dependency-injection: ^6.3 || ^7.0
- symfony/http-kernel: ^6
- symfony/yaml: 6.*
Requires (Dev)
- phpunit/phpunit: ^10.5
- symfony/phpunit-bridge: ^7.0
- symfony/test-pack: ^1.0
README
Install:
composer require siestacat/doctrine-odm-event-listener
Add bundle if not auto added:
Siestacat\DoctrineOdmEventListener\DoctrineOdmEventListenerBundle::class => ['all' => true]
Add attribute to your document:
use Siestacat\DoctrineOdmEventListener\EventListenerAttribute;
#[EventListenerAttribute(['App\EventListener\MyDocumentListener'])]
Example of MyDocumentListener:
namespace App\EventListener;
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs;
use App\Document\MyDocument;
class MyDocumentListener
{
public function postPersist(MyDocument $document, LifecycleEventArgs $event) {}
}
List of events:
preRemove
postRemove
prePersist
postPersist
preUpdate
postUpdate
preLoad
postLoad