From b53f881070f1fa0786aec60272efc01803b3efcf Mon Sep 17 00:00:00 2001 From: Andrej Hudec Date: Thu, 1 Aug 2024 13:45:00 +0200 Subject: [PATCH 1/2] Add IdentityBigIntTrait --- src/Entity/Traits/IdentityBigIntTrait.php | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/Entity/Traits/IdentityBigIntTrait.php diff --git a/src/Entity/Traits/IdentityBigIntTrait.php b/src/Entity/Traits/IdentityBigIntTrait.php new file mode 100644 index 0000000..a5cefab --- /dev/null +++ b/src/Entity/Traits/IdentityBigIntTrait.php @@ -0,0 +1,50 @@ + true])] + #[Serialize] + protected ?int $id = null; + + public function getId(): ?int + { + return $this->id; + } + + public function setId(?int $id): static + { + $this->id = $id; + + return $this; + } + + public function is(BaseIdentifiableInterface $identifiable): bool + { + if ($identifiable::getResourceName() === $this->getResourceName()) { + return $identifiable->getId() === $this->getId(); + } + + return false; + } + + public function isNot(BaseIdentifiableInterface $identifiable): bool + { + return false === $this->is($identifiable); + } +} From aecdb9a5ef9d5c660dff8f9530db7193fce67d09 Mon Sep 17 00:00:00 2001 From: Andrej Hudec Date: Thu, 1 Aug 2024 13:45:39 +0200 Subject: [PATCH 2/2] Mark `IdentityTrait` as deprecated --- src/Entity/Traits/IdentityTrait.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Entity/Traits/IdentityTrait.php b/src/Entity/Traits/IdentityTrait.php index de9ab3c..d1313f6 100644 --- a/src/Entity/Traits/IdentityTrait.php +++ b/src/Entity/Traits/IdentityTrait.php @@ -9,6 +9,9 @@ use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +/** + * @deprecated Use IdentityIntTrait + */ trait IdentityTrait { use NamedResourceTrait;