diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 65ba643..df0f4cc 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -10,11 +10,12 @@ defaults: jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: + fail-fast: false matrix: - php: ['7.4', '8.0', '8.1'] + php: ['8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout diff --git a/.gitignore b/.gitignore index e01bc6a..85e45a9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.phpunit.result.cache /composer.lock /phpunit.xml +/.idea diff --git a/composer.json b/composer.json index 8384b23..ec69d3a 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": ">=7.4", + "php": ">=8.0", "doctrine/dbal": "^2.9|^3.1.4", "doctrine/doctrine-bundle": "^2.2", "doctrine/orm": "^2.6", diff --git a/docs/labeler.md b/docs/labeler.md index 9fada17..990b564 100644 --- a/docs/labeler.md +++ b/docs/labeler.md @@ -22,14 +22,14 @@ class AuditLabler } ``` -Re-define the audit subscriber service to call the `setLabler` method of the `AuditSubscriber` with the [callable](https://www.php.net/manual/en/language.types.callable.php). +Re-define the audit listener service to call the `setLabler` method of the `AuditListener` with the [callable](https://www.php.net/manual/en/language.types.callable.php). `app/config/services.yml` ```yaml services: - datadog.event_subscriber.audit: - class: 'DataDog\AuditBundle\EventSubscriber\AuditSubscriber' + datadog.event_listener.audit: + class: 'DataDog\AuditBundle\EventListener\AuditListener' arguments: ['@security.token_storage'] tags: - { name: doctrine.event_subscriber, connection: default } diff --git a/src/DependencyInjection/DataDogAuditExtension.php b/src/DependencyInjection/DataDogAuditExtension.php index 134de9f..48cdd1e 100644 --- a/src/DependencyInjection/DataDogAuditExtension.php +++ b/src/DependencyInjection/DataDogAuditExtension.php @@ -17,16 +17,16 @@ public function load(array $configs, ContainerBuilder $container): void $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $auditSubscriber = $container->getDefinition('datadog.event_subscriber.audit'); + $auditListener = $container->getDefinition('datadog.event_listener.audit'); if (isset($config['audited_entities']) && !empty($config['audited_entities'])) { - $auditSubscriber->addMethodCall('addAuditedEntities', array($config['audited_entities'])); + $auditListener->addMethodCall('addAuditedEntities', array($config['audited_entities'])); } else if (isset($config['unaudited_entities'])) { - $auditSubscriber->addMethodCall('addUnauditedEntities', array($config['unaudited_entities'])); + $auditListener->addMethodCall('addUnauditedEntities', array($config['unaudited_entities'])); } if (isset($config['blame_impersonator'])) { - $auditSubscriber->addMethodCall('setBlameImpersonator', array($config['blame_impersonator'])); + $auditListener->addMethodCall('setBlameImpersonator', array($config['blame_impersonator'])); } } } diff --git a/src/EventSubscriber/AuditSubscriber.php b/src/EventListener/AuditListener.php similarity index 98% rename from src/EventSubscriber/AuditSubscriber.php rename to src/EventListener/AuditListener.php index c8228d4..d92d49a 100644 --- a/src/EventSubscriber/AuditSubscriber.php +++ b/src/EventListener/AuditListener.php @@ -1,6 +1,6 @@ getEntityManager(); $uow = $em->getUnitOfWork(); @@ -525,11 +525,6 @@ private function getRoles(TokenInterface $token) return $token->getRoles(); } - public function getSubscribedEvents(): array - { - return [Events::onFlush]; - } - public function setBlameUser(UserInterface $user) { $this->blameUser = $user; diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php index d2a6a44..caea8b2 100644 --- a/src/Resources/config/services.php +++ b/src/Resources/config/services.php @@ -2,7 +2,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use DataDog\AuditBundle\EventSubscriber\AuditSubscriber; +use DataDog\AuditBundle\EventListener\AuditListener; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; @@ -10,9 +10,10 @@ // @formatter:off $services = $container->services(); $services - ->set('datadog.event_subscriber.audit', AuditSubscriber::class)->private() + ->set('datadog.event_listener.audit', AuditListener::class)->private() ->arg(0, new Reference(TokenStorageInterface::class)) - ->tag('doctrine.event_subscriber') + //->tag('doctrine.event_subscriber') + ->tag('doctrine.event_listener', ['event' => 'onFlush',]) ; // @formatter:on }; diff --git a/tests/EventSubscriber/AuditSubscriberTest.php b/tests/EventListener/AuditListenerTest.php similarity index 96% rename from tests/EventSubscriber/AuditSubscriberTest.php rename to tests/EventListener/AuditListenerTest.php index 061579b..b084e20 100644 --- a/tests/EventSubscriber/AuditSubscriberTest.php +++ b/tests/EventListener/AuditListenerTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace DataDog\AuditBundle\Tests\EventSubscriber; +namespace DataDog\AuditBundle\Tests\EventListener; use DataDog\AuditBundle\Entity\AuditLog; use DataDog\AuditBundle\Tests\Entity\Post; use DataDog\AuditBundle\Tests\Entity\Tag; use DataDog\AuditBundle\Tests\OrmTestCase; -final class AuditSubscriberTest extends OrmTestCase +final class AuditListenerTest extends OrmTestCase { protected function setUp(): void {