code: static public function generateDoctrine2(\Doctrine\ORM\EntityManager $entityManager, $entityName, $field, $length = 16)
      {    
          do {
              $generate = self::generate($length);
          } while (self::doctrine2Query($entityManager, $entityName, $field, $generate));
          
          return $generate;
      }
docs: Doctrine v2.x generate method
  
  @param \Doctrine\ORM\EntityManager $entityManager
  @param string $entityName
  @param string $field
  @param int $length
  @return string