src/Common/Model/Base.php
protected function generateToken($sMask = null, $sTable = null, $sColumn = null)
    {
        if (is_null($sMask)) {
            $sMask = $this->sTokenMask;
        }

        if (is_null($sTable)) {
            $sTable = $this->getTableName();
        }

        if (is_null($sColumn)) {
            if (!$this->tableTokenColumn) {
                throw new ModelException(static::class . '::generateToken() Token variable not set', 1);
            }
            $sColumn = $this->tableTokenColumn;
        }

        $oDb = Factory::service('Database');

        do {
            $sToken = generateToken($sMask);
            $oDb->where($sColumn, $sToken);
        } while ($oDb->count_all_results($sTable));

        return $sToken;
    }
protected function generateToken($sMask = null, $sTable = null, $sColumn = null)
    {
        if (is_null($sMask)) {
            $sMask = $this->sTokenMask;
        }

        if (is_null($sTable)) {
            $sTable = $this->getTableName();
        }

        if (is_null($sColumn)) {
            if (!$this->tableTokenColumn) {
                throw new ModelException(static::class . '::generateToken() Token variable not set', 1);
            }
            $sColumn = $this->tableTokenColumn;
        }

        $oDb = Factory::service('Database');

        do {
            $sToken = generateToken($sMask);
            $oDb->where($sColumn, $sToken);
        } while ($oDb->count_all_results($sTable));

        return $sToken;
    }
protected function generateToken ( $ sMask = null , $ sTable = null , $ sColumn = null ) { if ( is_null ( $ sMask ) ) { $ sMask = $ this -> sTokenMask ; } if ( is_null ( $ sTable ) ) { $ sTable = $ this -> getTableName ( ) ; } if ( is_null ( $ sColumn ) ) { if ( ! $ this -> tableTokenColumn ) { throw new ModelException ( static :: class . '::generateToken() Token variable not set' , 1 ) ; } $ sColumn = $ this -> tableTokenColumn ; } $ oDb = Factory :: service ( 'Database' ) ; do { $ sToken = generateToken ( $ sMask ) ; $ oDb -> where ( $ sColumn , $ sToken ) ; } while ( $ oDb -> count_all_results ( $ sTable ) ) ; return $ sToken ; }
Generates a unique token for a record

@param string|null $sMask   The token mask, defaults to $this->sTokenMask
@param string|null $sTable  The table to use defaults to $this->table
@param string|null $sColumn The column to use, defaults to $this->tableTokenColumn

@return string
@throws ModelException
Generates a unique token for a record