Created
August 20, 2020 15:29
-
-
Save parijke/21318d60d6f0e5d7b4e639edfa93efee to your computer and use it in GitHub Desktop.
Symfony Uid as primary identifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Entity\Traits; | |
use Doctrine\ORM\Mapping as ORM; | |
use Symfony\Component\Uid\Uuid; | |
trait EntityIdTrait | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="string", length=36, unique=true) | |
* @ORM\GeneratedValue(strategy="CUSTOM") | |
* @ORM\CustomIdGenerator(class="App\Entity\Generator\UuidGenerator") | |
*/ | |
protected $id; | |
public function getId(): ?Uuid | |
{ | |
return $this->id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment