PHP Class yii\gii\generators\model\Generator

Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\gii\Generator
Afficher le fichier Open project: yiisoft/yii2-gii Class Usage Examples

Méthodes publiques

Свойство Type Description
$baseClass
$db
$generateLabelsFromComments
$generateQuery
$generateRelations
$generateRelationsFromCurrentSchema
$modelClass
$ns
$queryBaseClass
$queryClass
$queryNs
$tableName
$useSchemaName
$useTablePrefix

Protected Properties

Свойство Type Description
$classNames
$tableNames

Méthodes publiques

Méthode Description
attributeLabels ( )
autoCompleteData ( )
generate ( )
generateLabels ( yii\db\TableSchema $table ) : array Generates the attribute labels for the specified table.
generateRules ( yii\db\TableSchema $table ) : array Generates validation rules for the specified table.
generateTableName ( string $tableName ) : string Generates the table name by considering table prefix.
getDescription ( )
getName ( )
getTablePrefix ( ) : string Returns the tablePrefix property of the DB connection as specified
hints ( )
requiredTemplates ( )
rules ( )
stickyAttributes ( )
validateDb ( ) Validates the [[db]] attribute.
validateModelClass ( ) Validates the [[modelClass]] attribute.
validateNamespace ( string $attribute ) Validates the namespace.
validateTableName ( ) Validates the [[tableName]] attribute.

Méthodes protégées

Méthode Description
addInverseRelations ( array $relations ) : array Adds inverse relations
checkJunctionTable ( $table ) : array | boolean Checks if the given table is a junction table, that is it has at least one pair of unique foreign keys.
generateClassName ( string $tableName, boolean $useSchemaName = null ) : string Generates a class name from the specified table name.
generateQueryClassName ( string $modelClassName ) : string Generates a query class name from the specified model class name.
generateRelationLink ( array $refs ) : string Generates the link parameter to be used in generating the relation declaration.
generateRelationName ( array $relations, yii\db\TableSchema $table, string $key, boolean $multiple ) : string Generate a relation name for the specified table and a base name.
generateRelations ( ) : array
getDbConnection ( ) : Connection
getSchemaNames ( ) : string[]
getTableNames ( ) : array
isColumnAutoIncremental ( yii\db\TableSchema $table, array $columns ) : boolean Checks if any of the specified columns is auto incremental.
isHasManyRelation ( yii\db\TableSchema $table, array $fks ) : boolean Determines if relation is of has many type

Private Methods

Méthode Description
generateManyManyRelations ( $table, array $fks, array $relations ) : array Generates relations using a junction table by adding an extra viaTable().

Method Details

addInverseRelations() protected méthode

Adds inverse relations
Since: 2.0.5
protected addInverseRelations ( array $relations ) : array
$relations array relation declarations
Résultat array relation declarations extended with inverse relation names

attributeLabels() public méthode

public attributeLabels ( )

autoCompleteData() public méthode

public autoCompleteData ( )

checkJunctionTable() protected méthode

Checks if the given table is a junction table, that is it has at least one pair of unique foreign keys.
protected checkJunctionTable ( $table ) : array | boolean
Résultat array | boolean all unique foreign key pairs if the table is a junction table, or false if the table is not a junction table.

generate() public méthode

public generate ( )

generateClassName() protected méthode

Generates a class name from the specified table name.
protected generateClassName ( string $tableName, boolean $useSchemaName = null ) : string
$tableName string the table name (which may contain schema prefix)
$useSchemaName boolean should schema name be included in the class name, if present
Résultat string the generated class name

generateLabels() public méthode

Generates the attribute labels for the specified table.
public generateLabels ( yii\db\TableSchema $table ) : array
$table yii\db\TableSchema the table schema
Résultat array the generated attribute labels (name => label)

generateQueryClassName() protected méthode

Generates a query class name from the specified model class name.
protected generateQueryClassName ( string $modelClassName ) : string
$modelClassName string model class name
Résultat string generated class name

generateRelationName() protected méthode

Generate a relation name for the specified table and a base name.
protected generateRelationName ( array $relations, yii\db\TableSchema $table, string $key, boolean $multiple ) : string
$relations array the relations being generated currently.
$table yii\db\TableSchema the table schema
$key string a base name that the relation name may be generated from
$multiple boolean whether this is a has-many relation
Résultat string the relation name

generateRelations() protected méthode

protected generateRelations ( ) : array
Résultat array the generated relation declarations

generateRules() public méthode

Generates validation rules for the specified table.
public generateRules ( yii\db\TableSchema $table ) : array
$table yii\db\TableSchema the table schema
Résultat array the generated validation rules

generateTableName() public méthode

If [[useTablePrefix]] is false, the table name will be returned without change.
public generateTableName ( string $tableName ) : string
$tableName string the table name (which may contain schema prefix)
Résultat string the generated table name

getDbConnection() protected méthode

protected getDbConnection ( ) : Connection
Résultat yii\db\Connection the DB connection as specified by [[db]].

getDescription() public méthode

public getDescription ( )

getName() public méthode

public getName ( )

getSchemaNames() protected méthode

Since: 2.0.5
protected getSchemaNames ( ) : string[]
Résultat string[] all db schema names or an array with a single empty string

getTableNames() protected méthode

protected getTableNames ( ) : array
Résultat array the table names that match the pattern specified by [[tableName]].

getTablePrefix() public méthode

Returns the tablePrefix property of the DB connection as specified
See also: getDbConnection
Since: 2.0.5
public getTablePrefix ( ) : string
Résultat string

hints() public méthode

public hints ( )

isColumnAutoIncremental() protected méthode

Checks if any of the specified columns is auto incremental.
protected isColumnAutoIncremental ( yii\db\TableSchema $table, array $columns ) : boolean
$table yii\db\TableSchema the table schema
$columns array columns to check for autoIncrement property
Résultat boolean whether any of the specified columns is auto incremental.

isHasManyRelation() protected méthode

Determines if relation is of has many type
Since: 2.0.5
protected isHasManyRelation ( yii\db\TableSchema $table, array $fks ) : boolean
$table yii\db\TableSchema
$fks array
Résultat boolean

requiredTemplates() public méthode

public requiredTemplates ( )

rules() public méthode

public rules ( )

stickyAttributes() public méthode

public stickyAttributes ( )

validateDb() public méthode

Validates the [[db]] attribute.
public validateDb ( )

validateModelClass() public méthode

Validates the [[modelClass]] attribute.
public validateModelClass ( )

validateNamespace() public méthode

Validates the namespace.
public validateNamespace ( string $attribute )
$attribute string Namespace variable.

validateTableName() public méthode

Validates the [[tableName]] attribute.
public validateTableName ( )

Property Details

$baseClass public_oe property

public $baseClass

$classNames protected_oe property

protected $classNames

$db public_oe property

public $db

$generateLabelsFromComments public_oe property

public $generateLabelsFromComments

$generateQuery public_oe property

public $generateQuery

$generateRelations public_oe property

public $generateRelations

$generateRelationsFromCurrentSchema public_oe property

public $generateRelationsFromCurrentSchema

$modelClass public_oe property

public $modelClass

$ns public_oe property

public $ns

$queryBaseClass public_oe property

public $queryBaseClass

$queryClass public_oe property

public $queryClass

$queryNs public_oe property

public $queryNs

$tableName public_oe property

public $tableName

$tableNames protected_oe property

protected $tableNames

$useSchemaName public_oe property

public $useSchemaName

$useTablePrefix public_oe property

public $useTablePrefix