From 7191ece7a507d28a0f7bf6332d8d78a934c4ba5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 28 May 2023 01:55:30 +0200 Subject: [PATCH] Configure doctrine to use attributes instead of annotations --- config/packages/doctrine.yaml | 2 +- src/Entity/LogSystem/AbstractLogEntry.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index 5d255beb..1829473a 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -27,7 +27,7 @@ doctrine: mappings: App: is_bundle: false - type: annotation + type: attribute dir: '%kernel.project_dir%/src/Entity' prefix: 'App\Entity' alias: App diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php index 95bb7b76..f2ca701c 100644 --- a/src/Entity/LogSystem/AbstractLogEntry.php +++ b/src/Entity/LogSystem/AbstractLogEntry.php @@ -46,18 +46,19 @@ use DateTime; use Doctrine\ORM\Mapping as ORM; use InvalidArgumentException; use Psr\Log\LogLevel; +use App\Repository\LogEntryRepository; /** * This entity describes an entry in the event log. */ -#[ORM\Entity(repositoryClass: 'App\Repository\LogEntryRepository')] +#[ORM\Entity(repositoryClass: LogEntryRepository::class)] +#[ORM\Table('log')] #[ORM\InheritanceType('SINGLE_TABLE')] #[ORM\DiscriminatorColumn(name: 'type', type: 'smallint')] #[ORM\DiscriminatorMap([1 => 'UserLoginLogEntry', 2 => 'UserLogoutLogEntry', 3 => 'UserNotAllowedLogEntry', 4 => 'ExceptionLogEntry', 5 => 'ElementDeletedLogEntry', 6 => 'ElementCreatedLogEntry', 7 => 'ElementEditedLogEntry', 8 => 'ConfigChangedLogEntry', 9 => 'LegacyInstockChangedLogEntry', 10 => 'DatabaseUpdatedLogEntry', 11 => 'CollectionElementDeleted', 12 => 'SecurityEventLogEntry', 13 => 'PartStockChangedLogEntry'])] -#[ORM\Table('log')] -#[ORM\Index(name: 'log_idx_type', columns: ['type'])] -#[ORM\Index(name: 'log_idx_type_target', columns: ['type', 'target_type', 'target_id'])] -#[ORM\Index(name: 'log_idx_datetime', columns: ['datetime'])] +#[ORM\Index(columns: ['type'], name: 'log_idx_type')] +#[ORM\Index(columns: ['type', 'target_type', 'target_id'], name: 'log_idx_type_target')] +#[ORM\Index(columns: ['datetime'], name: 'log_idx_datetime')] abstract class AbstractLogEntry extends AbstractDBElement { public const LEVEL_EMERGENCY = 0;