Skip to content

Commit

Permalink
Add priority to #[AsDocumentListener] (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN authored Dec 21, 2023
1 parent 6bec2f0 commit 49bfb83
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Attribute/AsDocumentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __construct(
public ?string $method = null,
public ?bool $lazy = null,
public ?string $connection = null,
public ?int $priority = null,
) {
}
}
1 change: 1 addition & 0 deletions DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function load(array $configs, ContainerBuilder $container)
'method' => $attribute->method,
'lazy' => $attribute->lazy,
'connection' => $attribute->connection,
'priority' => $attribute->priority,
]);
});

Expand Down
1 change: 1 addition & 0 deletions Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function testAsDocumentListenerAttribute(): void
'method' => 'onPrePersist',
'lazy' => true,
'connection' => 'test',
'priority' => 10,
],
], $listenerDefinition->getTag('doctrine_mongodb.odm.event_listener'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49bfb83

Please sign in to comment.