public function getNewUniqRandomKey(ObjectRepository $repository, $field, $length)
    {
        $entity = true;
        while ($entity) {
            $random = $this->randomStr($length);
            $entity = $repository->findOneBy(array($field => $random));
        }

        return $random;
    }
public function getNewUniqRandomKey(ObjectRepository $repository, $field, $length)
    {
        $entity = true;
        while ($entity) {
            $random = $this->randomStr($length);
            $entity = $repository->findOneBy(array($field => $random));
        }

        return $random;
    }
public function getNewUniqRandomKey ( ObjectRepository $ repository , $ field , $ length ) { $ entity = true ; while ( $ entity ) { $ random = $ this -> randomStr ( $ length ) ; $ entity = $ repository -> findOneBy ( array ( $ field => $ random ) ) ; } return $ random ; }
Get a new random uniq key for a specific field on a given repository.

@param ObjectRepository $repository The repository
@param string           $field      Field name
@param int              $length     Random string length

@return string
Get a new random uniq key for a specific field on a given repository .