From d8add9291f0184c29ec6c1b7e082915e4dafce6a Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 15 Jan 2023 13:12:17 +0100 Subject: [PATCH] Removed public readonly prop from entity, as it can cause errors when a proxy is generated --- module/Core/src/ShortUrl/Entity/DeviceLongUrl.php | 7 ++++++- module/Core/src/ShortUrl/Entity/ShortUrl.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/module/Core/src/ShortUrl/Entity/DeviceLongUrl.php b/module/Core/src/ShortUrl/Entity/DeviceLongUrl.php index 668741e8..315f7f38 100644 --- a/module/Core/src/ShortUrl/Entity/DeviceLongUrl.php +++ b/module/Core/src/ShortUrl/Entity/DeviceLongUrl.php @@ -12,7 +12,7 @@ class DeviceLongUrl extends AbstractEntity { private function __construct( private readonly ShortUrl $shortUrl, // No need to read this field. It's used by doctrine - public readonly DeviceType $deviceType, + private readonly DeviceType $deviceType, private string $longUrl, ) { } @@ -27,6 +27,11 @@ class DeviceLongUrl extends AbstractEntity return $this->longUrl; } + public function deviceType(): DeviceType + { + return $this->deviceType; + } + public function updateLongUrl(string $longUrl): void { $this->longUrl = $longUrl; diff --git a/module/Core/src/ShortUrl/Entity/ShortUrl.php b/module/Core/src/ShortUrl/Entity/ShortUrl.php index 644c52eb..3a1b7329 100644 --- a/module/Core/src/ShortUrl/Entity/ShortUrl.php +++ b/module/Core/src/ShortUrl/Entity/ShortUrl.php @@ -170,7 +170,7 @@ class ShortUrl extends AbstractEntity } foreach ($shortUrlEdit->deviceLongUrls as $deviceLongUrlPair) { $deviceLongUrl = $this->deviceLongUrls->findFirst( - fn ($_, DeviceLongUrl $d) => $d->deviceType === $deviceLongUrlPair->deviceType, + fn ($_, DeviceLongUrl $d) => $d->deviceType() === $deviceLongUrlPair->deviceType, ); if ($deviceLongUrl !== null) { @@ -322,7 +322,7 @@ class ShortUrl extends AbstractEntity { $data = []; foreach ($this->deviceLongUrls as $deviceUrl) { - $data[$deviceUrl->deviceType->value] = $deviceUrl->longUrl(); + $data[$deviceUrl->deviceType()->value] = $deviceUrl->longUrl(); } return $data;