Create service to generate a unique id. #638

This commit is contained in:
Korina Cordero 2021-11-09 08:33:11 +00:00
parent ee07c9cc84
commit d6cf2de4ab

View file

@ -0,0 +1,22 @@
<?php
namespace App\Service;
use Doctrine\ORM\EntityManagerInterface;
class UniqueIdGenerator
{
protected $em;
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
public function generateUniqueId($str_length)
{
// TODO: retry until we get a unique id
return substr(md5(time()), 0, $str_length);
}
}