diff --git a/Attribute/AsEventListener.php b/Attribute/AsDoctrineListener.php similarity index 93% rename from Attribute/AsEventListener.php rename to Attribute/AsDoctrineListener.php index 16b04e571..ed3c7b7d1 100644 --- a/Attribute/AsEventListener.php +++ b/Attribute/AsDoctrineListener.php @@ -8,7 +8,7 @@ * Service tag to autoconfigure event listeners. */ #[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)] -class AsEventListener +class AsDoctrineListener { public function __construct( public string $event, diff --git a/DependencyInjection/DoctrineExtension.php b/DependencyInjection/DoctrineExtension.php index 46e4e85d0..d7454ae93 100644 --- a/DependencyInjection/DoctrineExtension.php +++ b/DependencyInjection/DoctrineExtension.php @@ -2,8 +2,8 @@ namespace Doctrine\Bundle\DoctrineBundle\DependencyInjection; +use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener; use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener; -use Doctrine\Bundle\DoctrineBundle\Attribute\AsEventListener; use Doctrine\Bundle\DoctrineBundle\Attribute\AsMiddleware; use Doctrine\Bundle\DoctrineBundle\CacheWarmer\DoctrineMetadataCacheWarmer; use Doctrine\Bundle\DoctrineBundle\Dbal\ManagerRegistryAwareConnectionProvider; @@ -505,7 +505,7 @@ protected function ormLoad(array $config, ContainerBuilder $container) 'entity' => $attribute->entity, ]); }); - $container->registerAttributeForAutoconfiguration(AsEventListener::class, static function (ChildDefinition $definition, AsEventListener $attribute) { + $container->registerAttributeForAutoconfiguration(AsDoctrineListener::class, static function (ChildDefinition $definition, AsDoctrineListener $attribute) { $definition->addTag('doctrine.event_listener', [ 'event' => $attribute->event, 'priority' => $attribute->priority, diff --git a/Tests/DependencyInjection/DoctrineExtensionTest.php b/Tests/DependencyInjection/DoctrineExtensionTest.php index 2aca7c61f..69ba316a5 100644 --- a/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -3,8 +3,8 @@ namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection; use Closure; +use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener; use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener; -use Doctrine\Bundle\DoctrineBundle\Attribute\AsEventListener; use Doctrine\Bundle\DoctrineBundle\CacheWarmer\DoctrineMetadataCacheWarmer; use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\CacheCompatibilityPass; use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; @@ -1113,7 +1113,7 @@ public function testAsEntityListenerAttribute() } /** @requires PHP 8 */ - public function testAsEventListenerAttribute() + public function testAsDoctrineListenerAttribute() { $container = $this->getContainer(); $extension = new DoctrineExtension(); @@ -1126,14 +1126,14 @@ public function testAsEventListenerAttribute() $extension->load([$config], $container); $attributes = $container->getAutoconfiguredAttributes(); - $this->assertInstanceOf(Closure::class, $attributes[AsEventListener::class]); + $this->assertInstanceOf(Closure::class, $attributes[AsDoctrineListener::class]); $reflector = new ReflectionClass(Php8EventListener::class); $definition = new ChildDefinition(''); /** @psalm-suppress UndefinedMethod */ - $attribute = $reflector->getAttributes(AsEventListener::class)[0]->newInstance(); + $attribute = $reflector->getAttributes(AsDoctrineListener::class)[0]->newInstance(); - $attributes[AsEventListener::class]($definition, $attribute); + $attributes[AsDoctrineListener::class]($definition, $attribute); $expected = [ 'event' => Events::postFlush, diff --git a/Tests/DependencyInjection/Fixtures/Php8EventListener.php b/Tests/DependencyInjection/Fixtures/Php8EventListener.php index a06b57b0d..9c18753dd 100644 --- a/Tests/DependencyInjection/Fixtures/Php8EventListener.php +++ b/Tests/DependencyInjection/Fixtures/Php8EventListener.php @@ -2,10 +2,10 @@ namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Fixtures; -use Doctrine\Bundle\DoctrineBundle\Attribute\AsEventListener; +use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener; use Doctrine\ORM\Events; -#[AsEventListener(Events::postFlush)] +#[AsDoctrineListener(Events::postFlush)] final class Php8EventListener { public function postFlush(): void