From b11628ac41a4119918b51b38f6c8572704967507 Mon Sep 17 00:00:00 2001 From: Miky Mikolaj Date: Sun, 17 Jan 2021 17:34:39 +0100 Subject: [PATCH] getId(): ?Uuid missing // need test getId: ?Ulid I added all code as in example, but i had still issue with api-platform that getId() field is wrong defined... I have no experience with ULID !!! Please test my solution for This solved my issue.. and now i am able create, update or delete record without any other issues. I think that this will save lot of time for new users... because fist i thinked that must be public function getId(): ?UuidV4Generator { return $this->id; } but with this my code was still broken... now i know that there must be if you change primary identifier from Int to Uuid use Symfony\Component\Uid\Uuid; public function getId(): ?Uuid { return $this->id; } .... also i think need to done the section of Uuid and Ulid for private $someProperty; getter and setter --- components/uid.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/uid.rst b/components/uid.rst index bdeb252bb65..a7fb95d5d2f 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -141,6 +141,7 @@ entity primary keys:: // there are generators for UUID V1 and V6 too use Symfony\Bridge\Doctrine\IdGenerator\UuidV4Generator; + use Symfony\Component\Uid\Uuid; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") @@ -156,6 +157,13 @@ entity primary keys:: private $id; // ... + + public function getId(): ?Uuid + { + return $this->id; + } + + // ... } .. versionadded:: 5.2 @@ -279,6 +287,7 @@ There's also a Doctrine generator to help autogenerate ULID values for the entity primary keys:: use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator; + use Symfony\Component\Uid\Ulid; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") @@ -294,6 +303,14 @@ entity primary keys:: private $id; // ... + + public function getId(): ?Ulid + { + return $this->id; + } + + // ... + } .. versionadded:: 5.2