Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename AsEventListener to AsDoctrineListener #1592

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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