Skip to content

Commit

Permalink
Rename AsEventListener to AsDoctrineListener
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Dec 8, 2022
1 parent d127f9a commit 4a0423a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions Tests/DependencyInjection/DoctrineExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1113,7 +1113,7 @@ public function testAsEntityListenerAttribute()
}

/** @requires PHP 8 */
public function testAsEventListenerAttribute()
public function testAsDoctrineListenerAttribute()
{
$container = $this->getContainer();
$extension = new DoctrineExtension();
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions Tests/DependencyInjection/Fixtures/Php8EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a0423a

Please sign in to comment.