Skip to content

Instantly share code, notes, and snippets.

@parijke
Created August 20, 2020 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parijke/c042ceebc1e3983c55e182fe047d8a88 to your computer and use it in GitHub Desktop.
Save parijke/c042ceebc1e3983c55e182fe047d8a88 to your computer and use it in GitHub Desktop.
Generator
<?php
namespace App\Entity\Generator;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Id\AbstractIdGenerator;
use Symfony\Component\Uid\Uuid;
class UuidGenerator extends AbstractIdGenerator
{
/**
* Generates an identifier for an entity.
*
* @param EntityManager $em
* @param object|null $entity
* @return mixed
*/
public function generate(EntityManager $em, $entity): uuid {
return uuid::v4();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment