From 27510280a6b782ec8ad2dbd934fd4b978396bedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 20 Dec 2023 18:20:52 +0100 Subject: [PATCH] Add priority to #[AsDocumentListener] --- Attribute/AsDocumentListener.php | 1 + DependencyInjection/DoctrineMongoDBExtension.php | 1 + Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php | 1 + .../EventListener/TestAttributeListener.php | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) 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