Skip to content

Commit

Permalink
Merge pull request #33 from whitedigital-eu/feature/symfony-6.3-upgrade
Browse files Browse the repository at this point in the history
Bump to Symfony 6.3 support
  • Loading branch information
acirulis authored Nov 9, 2023
2 parents ab51488 + 8fa0d27 commit d7de031
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.phar
/vendor
phpunit.xml
*.cache
.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ means of storage.
### System Requirements
PHP 8.1+
Symfony 6.2+
Symfony 6.3+
### Project Requirements
**2 separate Doctrine entity managers (*if using provided AuditService*)**
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"doctrine/doctrine-bundle": "*",
"doctrine/orm": "*",
"doctrine/persistence": "*",
"symfony/config": "^6.2",
"symfony/console": "^6.2",
"symfony/dependency-injection": "^6.2",
"symfony/event-dispatcher": "^6.2",
"symfony/http-foundation": "^6.2",
"symfony/http-kernel": "^6.2",
"symfony/config": "^6.3",
"symfony/console": "^6.3",
"symfony/dependency-injection": "^6.3",
"symfony/event-dispatcher": "^6.3",
"symfony/http-foundation": "^6.3",
"symfony/http-kernel": "^6.3",
"symfony/maker-bundle": "*",
"symfony/security-bundle": "^6.2",
"symfony/serializer": "^6.2",
"symfony/translation": "^6.2",
"symfony/validator": "^6.2",
"whitedigital-eu/entity-resource-mapper-bundle": "^0.23"
"symfony/security-bundle": "^6.3",
"symfony/serializer": "^6.3",
"symfony/translation": "^6.3",
"symfony/validator": "^6.3",
"whitedigital-eu/entity-resource-mapper-bundle": "^0.24"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
Expand Down
24 changes: 11 additions & 13 deletions src/EventSubscriber/AuditDoctrineEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace WhiteDigital\Audit\EventSubscriber;

use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface;
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
use Doctrine\ORM\Event\PostPersistEventArgs;
use Doctrine\ORM\Event\PostUpdateEventArgs;
use Doctrine\ORM\Event\PreRemoveEventArgs;
use Doctrine\ORM\Events;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Persistence\Event\LifecycleEventArgs;
Expand All @@ -19,7 +22,10 @@
use function in_array;
use function sprintf;

class AuditDoctrineEventSubscriber implements EventSubscriberInterface
#[AsDoctrineListener(event: Events::postPersist, connection: 'default')]
#[AsDoctrineListener(event: Events::preRemove, connection: 'default')]
#[AsDoctrineListener(event: Events::postUpdate, connection: 'default')]
class AuditDoctrineEventSubscriber
{
public function __construct(
private readonly AuditServiceInterface $audit,
Expand All @@ -33,26 +39,18 @@ public function setIsEnabled(bool $isEnabled): void
$this->isEnabled = $isEnabled;
}

public function getSubscribedEvents(): array
{
return [
Events::postPersist,
Events::preRemove,
Events::postUpdate,
];
}

public function postPersist(LifecycleEventArgs $args): void
public function postPersist(PostPersistEventArgs $args): void
{
$this->logActivity(Events::postPersist, $this->translator->trans('entity.create', domain: 'Audit'), $args);
}

public function preRemove(LifecycleEventArgs $args): void
public function preRemove(PreRemoveEventArgs $args): void
{
$this->logActivity(Events::preRemove, $this->translator->trans('entity.remove', domain: 'Audit'), $args);
}

public function postUpdate(LifecycleEventArgs $args): void
public function postUpdate(PostUpdateEventArgs $args): void
{
$this->logActivity(Events::postUpdate, $this->translator->trans('entity.update', domain: 'Audit'), $args);
}
Expand Down

0 comments on commit d7de031

Please sign in to comment.