src/gii/auth/Generator.php
/**
     * Generates a class name from the specified table name.
     * @param string $tableName the table name (which may contain schema prefix)
     * @param bool $useSchemaName should schema name be included in the class name, if present
     * @return string the generated class name
     */
Generates a class name from the specified table name.
@param string $tableName the table name (which may contain schema prefix)
@param bool $useSchemaName should schema name be included in the class name, if present
@return string the generated class name
Generates a class name from the specified table name . @param string $tableName the table name ( which may contain schema prefix ) @param bool $useSchemaName should schema name be included in the class name if present @return string the generated class name
protected function generateClassName($tableName, $useSchemaName = null)
    {
        if (isset($this->classNames[$tableName])) {
            return $this->classNames[$tableName];
        }
        $schemaName = '';
        $fullTableName = $tableName;
        if (($pos = strrpos($tableName, '.')) !== false) {
            if (($useSchemaName === null && $this->useSchemaName) || $useSchemaName) {
                $schemaName = substr($tableName, 0, $pos) . '_';
            }
            $tableName = substr($tableName, $pos + 1);
        }
        $db = $this->getDbConnection();
        $patterns = [];
        $patterns[] = "/^{$db->tablePrefix}(.*?)$/";
        $patterns[] = "/^(.*?){$db->tablePrefix}$/";
        if (strpos($this->tableName, '*') !== false) {
            $pattern = $this->tableName;
            if (($pos = strrpos($pattern, '.')) !== false) {
                $pattern = substr($pattern, $pos + 1);
            }
            $patterns[] = '/^' . str_replace('*', '(\w+)', $pattern) . '$/';
        }
        $className = $tableName;
        foreach ($patterns as $pattern) {
            if (preg_match($pattern, $tableName, $matches)) {
                $className = $matches[1];
                break;
            }
        }
        if ($this->standardizeCapitals) {
            $schemaName = ctype_upper(preg_replace('/[_-]/', '', $schemaName)) ? strtolower($schemaName) : $schemaName;
            $className = ctype_upper(preg_replace('/[_-]/', '', $className)) ? strtolower($className) : $className;
            return $this->classNames[$fullTableName] = Inflector::camelize(Inflector::camel2words($schemaName.$className));
        } else {
            return $this->classNames[$fullTableName] = Inflector::id2camel($schemaName.$className, '_');
        }
    }
protected function generateClassName ( $ tableName , $ useSchemaName = null ) { if ( isset ( $ this -> classNames [ $ tableName ] ) ) { return $ this -> classNames [ $ tableName ] ; } $ schemaName = '' ; $ fullTableName = $ tableName ; if ( ( $ pos = strrpos ( $ tableName , '.' ) ) !== false ) { if ( ( $ useSchemaName === null && $ this -> useSchemaName ) || $ useSchemaName ) { $ schemaName = substr ( $ tableName , 0 , $ pos ) . '_' ; } $ tableName = substr ( $ tableName , $ pos + 1 ) ; } $ db = $ this -> getDbConnection ( ) ; $ patterns = [ ] ; $ patterns [ ] = " /^ { $ db -> tablePrefix } (.*?)$/ " ; $ patterns [ ] = " /^(.*?) { $ db -> tablePrefix } $/ " ; if ( strpos ( $ this -> tableName , '*' ) !== false ) { $ pattern = $ this -> tableName ; if ( ( $ pos = strrpos ( $ pattern , '.' ) ) !== false ) { $ pattern = substr ( $ pattern , $ pos + 1 ) ; } $ patterns [ ] = '/^' . str_replace ( '*' , '(\w+)' , $ pattern ) . '$/' ; } $ className = $ tableName ; foreach ( $ patterns as $ pattern ) { if ( preg_match ( $ pattern , $ tableName , $ matches ) ) { $ className = $ matches [ 1 ] ; break ; } } if ( $ this -> standardizeCapitals ) { $ schemaName = ctype_upper ( preg_replace ( '/[_-]/' , '' , $ schemaName ) ) ? strtolower ( $ schemaName ) : $ schemaName ; $ className = ctype_upper ( preg_replace ( '/[_-]/' , '' , $ className ) ) ? strtolower ( $ className ) : $ className ; return $ this -> classNames [ $ fullTableName ] = Inflector :: camelize ( Inflector :: camel2words ( $ schemaName . $ className ) ) ; } else { return $ this -> classNames [ $ fullTableName ] = Inflector :: id2camel ( $ schemaName . $ className , '_' ) ; } }
Generates a class name from the specified table name.
Generates a class name from the specified table name .