bundle/Entity/Repository/EzUserAccountKeyRepository.php
public function create($userId): EzUserAccountKey
    {
        $this->removeByUserId($userId);

        $randomBytes = false;

        if (function_exists('openssl_random_pseudo_bytes')) {
            $randomBytes = openssl_random_pseudo_bytes(32);
        }

        if ($randomBytes === false) {
            $randomBytes = mt_rand();
        }

        $hash = md5($userId . ':' . microtime() . ':' . $randomBytes);

        $userAccount = new EzUserAccountKey();
        $userAccount->setHash($hash);
        $userAccount->setTime(time());
        $userAccount->setUserId($userId);

        $this->getEntityManager()->persist($userAccount);
        $this->getEntityManager()->flush();

        return $userAccount;
    }
public function create($userId): EzUserAccountKey
    {
        $this->removeByUserId($userId);

        $randomBytes = false;

        if (function_exists('openssl_random_pseudo_bytes')) {
            $randomBytes = openssl_random_pseudo_bytes(32);
        }

        if ($randomBytes === false) {
            $randomBytes = mt_rand();
        }

        $hash = md5($userId . ':' . microtime() . ':' . $randomBytes);

        $userAccount = new EzUserAccountKey();
        $userAccount->setHash($hash);
        $userAccount->setTime(time());
        $userAccount->setUserId($userId);

        $this->getEntityManager()->persist($userAccount);
        $this->getEntityManager()->flush();

        return $userAccount;
    }
public function create ( $ userId ) : EzUserAccountKey { $ this -> removeByUserId ( $ userId ) ; $ randomBytes = false ; if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ randomBytes = openssl_random_pseudo_bytes ( 32 ) ; } if ( $ randomBytes === false ) { $ randomBytes = mt_rand ( ) ; } $ hash = md5 ( $ userId . ':' . microtime ( ) . ':' . $ randomBytes ) ; $ userAccount = new EzUserAccountKey ( ) ; $ userAccount -> setHash ( $ hash ) ; $ userAccount -> setTime ( time ( ) ) ; $ userAccount -> setUserId ( $ userId ) ; $ this -> getEntityManager ( ) -> persist ( $ userAccount ) ; $ this -> getEntityManager ( ) -> flush ( ) ; return $ userAccount ; }
Creates a user account key.

@param mixed $userId

@return \Netgen\Bundle\SiteBundle\Entity\EzUserAccountKey
Creates a user account key .