mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Migrated deprecated doctrine event subscribers to doctrine event listeners
This commit is contained in:
parent
d991643b0e
commit
f9d47e0865
3 changed files with 13 additions and 24 deletions
|
@ -76,7 +76,7 @@ services:
|
|||
# Only the event classes specified here are saved to DB (set to []) to log all events
|
||||
$whitelist: []
|
||||
|
||||
App\EventSubscriber\LogSystem\EventLoggerSubscriber:
|
||||
App\EventListener\LogSystem\EventLoggerListener:
|
||||
arguments:
|
||||
$save_changed_fields: '%env(bool:HISTORY_SAVE_CHANGED_FIELDS)%'
|
||||
$save_changed_data: '%env(bool:HISTORY_SAVE_CHANGED_DATA)%'
|
||||
|
@ -85,7 +85,7 @@ services:
|
|||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
App\EventSubscriber\LogSystem\LogDBMigrationSubscriber:
|
||||
App\EventListener\LogSystem\LogDBMigrationListener:
|
||||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
namespace App\EventListener\LogSystem;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
|
@ -38,7 +38,7 @@ use App\Entity\UserSystem\User;
|
|||
use App\Services\LogSystem\EventCommentHelper;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
use App\Services\LogSystem\EventUndoHelper;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Event\OnFlushEventArgs;
|
||||
use Doctrine\ORM\Event\PostFlushEventArgs;
|
||||
|
@ -50,7 +50,10 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
/**
|
||||
* This event subscriber writes to the event log when entities are changed, removed, created.
|
||||
*/
|
||||
class EventLoggerSubscriber implements EventSubscriber
|
||||
#[AsDoctrineListener(Events::onFlush)]
|
||||
#[AsDoctrineListener(Events::postPersist)]
|
||||
#[AsDoctrineListener(Events::postFlush)]
|
||||
class EventLoggerListener
|
||||
{
|
||||
/**
|
||||
* @var array The given fields will not be saved, because they contain sensitive information
|
||||
|
@ -187,14 +190,6 @@ class EventLoggerSubscriber implements EventSubscriber
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getSubscribedEvents(): array
|
||||
{
|
||||
return[
|
||||
Events::onFlush,
|
||||
Events::postPersist,
|
||||
Events::postFlush,
|
||||
];
|
||||
}
|
||||
|
||||
protected function logElementDeleted(AbstractDBElement $entity, EntityManagerInterface $em): void
|
||||
{
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
namespace App\EventListener\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\DatabaseUpdatedLogEntry;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
||||
use Doctrine\Migrations\DependencyFactory;
|
||||
use Doctrine\Migrations\Event\MigrationsEventArgs;
|
||||
use Doctrine\Migrations\Events;
|
||||
|
@ -32,7 +32,9 @@ use Doctrine\Migrations\Events;
|
|||
/**
|
||||
* This subscriber logs databaseMigrations to Event log.
|
||||
*/
|
||||
class LogDBMigrationSubscriber implements EventSubscriber
|
||||
#[AsDoctrineListener(Events::onMigrationsMigrated)]
|
||||
#[AsDoctrineListener(Events::onMigrationsMigrating)]
|
||||
class LogDBMigrationListener
|
||||
{
|
||||
protected ?string $old_version = null;
|
||||
protected ?string $new_version = null;
|
||||
|
@ -76,12 +78,4 @@ class LogDBMigrationSubscriber implements EventSubscriber
|
|||
$this->old_version = (string) $aliasResolver->resolveVersionAlias('current');
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
Events::onMigrationsMigrated,
|
||||
Events::onMigrationsMigrating,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue