diff --git a/Attribute/AsDocumentListener.php b/Attribute/AsDocumentListener.php index 0c73e8ce..ed7cbce6 100644 --- a/Attribute/AsDocumentListener.php +++ b/Attribute/AsDocumentListener.php @@ -17,6 +17,7 @@ public function __construct( public ?string $method = null, public ?bool $lazy = null, public ?string $connection = null, + public ?int $priority = null, ) { } } diff --git a/DependencyInjection/DoctrineMongoDBExtension.php b/DependencyInjection/DoctrineMongoDBExtension.php index df23fe9d..1a5c9693 100644 --- a/DependencyInjection/DoctrineMongoDBExtension.php +++ b/DependencyInjection/DoctrineMongoDBExtension.php @@ -141,6 +141,7 @@ public function load(array $configs, ContainerBuilder $container) 'method' => $attribute->method, 'lazy' => $attribute->lazy, 'connection' => $attribute->connection, + 'priority' => $attribute->priority, ]); }); diff --git a/Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php b/Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php index fbe69742..5565f312 100644 --- a/Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php @@ -97,6 +97,7 @@ public function testAsDocumentListenerAttribute(): void 'method' => 'onPrePersist', 'lazy' => true, 'connection' => 'test', + 'priority' => 10, ], ], $listenerDefinition->getTag('doctrine_mongodb.odm.event_listener')); } diff --git a/Tests/DependencyInjection/Fixtures/Bundles/DocumentListenerBundle/EventListener/TestAttributeListener.php b/Tests/DependencyInjection/Fixtures/Bundles/DocumentListenerBundle/EventListener/TestAttributeListener.php index b0b1935b..54479848 100644 --- a/Tests/DependencyInjection/Fixtures/Bundles/DocumentListenerBundle/EventListener/TestAttributeListener.php +++ b/Tests/DependencyInjection/Fixtures/Bundles/DocumentListenerBundle/EventListener/TestAttributeListener.php @@ -6,7 +6,7 @@ use Doctrine\Bundle\MongoDBBundle\Attribute\AsDocumentListener; -#[AsDocumentListener(event: 'prePersist', method: 'onPrePersist', lazy: true, connection: 'test')] +#[AsDocumentListener(event: 'prePersist', method: 'onPrePersist', lazy: true, connection: 'test', priority: 10)] class TestAttributeListener { public function onPrePersist(): void