PHP Class schmunk42\giiant\generators\model\Generator

Since: 0.0.1
Author: Tobias Munk ([email protected])
Inheritance: extends yii\gii\generators\model\Generator
Show file Open project: schmunk42/yii2-giiant Class Usage Examples

Public Properties

Property Type Description
$baseClassSuffix suffix to append to the base model, setting "Base" will result in a model named "PostBase"
$baseTraits base-traits
$createdAtColumn the name of the column where the user who updated the entry is stored
$createdByColumn the name of the column where the user who created the entry is stored
$generateHintsFromComments This indicates whether the generator should generate attribute hints by using the comments of the corresponding DB columns
$generateModelClass whether to overwrite (extended) model classes, will be always created, if file does not exist
$languageCodeColumn the column name where the language code is stored
$languageTableName the name of the table containing the translations. {{table}} will be replaced with the value in "Table Name" field
$messageCategory
$removeDuplicateRelations
$savedForm form field for selecting and loading saved gii forms
$singularEntities
$tableNameMap key-value pairs for mapping a table-name to class-name, eg. 'prefix_FOObar' => 'FooBar'
$tablePrefix string for the table prefix, which is ignored in generated class name
$updatedAtColumn the name of the column where the user who updated the entry is stored
$updatedByColumn the name of the column where the user who updated the entry is stored
$useBlameableBehavior whether or not to use BlameableBehavior
$useTimestampBehavior whether or not to use TimestampBehavior
$useTranslatableBehavior whether or not to use 2amigos/yii2-translateable-behavior

Protected Properties

Property Type Description
$classNames2

Public Methods

Method Description
attributeLabels ( )
formAttributes ( ) : array all form fields for saving in saved forms.
generate ( )
generateClassName ( string $tableName, $useSchemaName = null ) : string Generates a class name from the specified table name.
generateHints ( yii\db\TableSchema $table ) : array Generates the attribute hints for the specified table.
generateRelationName ( $relations, $table, $key, $multiple )
generateRules ( yii\db\TableSchema $table ) : array Generates validation rules for the specified table and add enum value validation.
getDescription ( )
getEnum ( array $columns ) : array prepare ENUM field values.
getName ( )
getTableNames ( )
hints ( )
isEnum ( $column ) : type validate is ENUM.
requiredTemplates ( )
rules ( )
validateDb ( ) Validates the [[db]] attribute.

Protected Methods

Method Description
extractTranslations ( $tableName, $relations ) : array
generateBlameable ( yii\db\TableSchema $table ) : string[]
generateRelations ( )
generateTimestamp ( yii\db\TableSchema $table ) : string[]
getDbConnection ( ) : Connection

Method Details

attributeLabels() public method

public attributeLabels ( )

extractTranslations() protected method

protected extractTranslations ( $tableName, $relations ) : array
$relations all database's relations
return array associative array containing the extracted relations and the modified translations

formAttributes() public method

all form fields for saving in saved forms.
public formAttributes ( ) : array
return array

generate() public method

public generate ( )

generateBlameable() protected method

protected generateBlameable ( yii\db\TableSchema $table ) : string[]
$table yii\db\TableSchema the table schema
return string[]

generateClassName() public method

Generates a class name from the specified table name.
public generateClassName ( string $tableName, $useSchemaName = null ) : string
$tableName string the table name (which may contain schema prefix)
return string the generated class name

generateHints() public method

Generates the attribute hints for the specified table.
public generateHints ( yii\db\TableSchema $table ) : array
$table yii\db\TableSchema the table schema
return array the generated attribute hints (name => hint) or an empty array if $this->generateHintsFromComments is false

generateRelationName() public method

public generateRelationName ( $relations, $table, $key, $multiple )

generateRelations() protected method

protected generateRelations ( )

generateRules() public method

Generates validation rules for the specified table and add enum value validation.
public generateRules ( yii\db\TableSchema $table ) : array
$table yii\db\TableSchema the table schema
return array the generated validation rules

generateTimestamp() protected method

protected generateTimestamp ( yii\db\TableSchema $table ) : string[]
$table yii\db\TableSchema the table schema
return string[]

getDbConnection() protected method

protected getDbConnection ( ) : Connection
return yii\db\Connection the DB connection from the DI container or as application component specified by [[db]]

getDescription() public method

public getDescription ( )

getEnum() public method

prepare ENUM field values.
public getEnum ( array $columns ) : array
$columns array
return array

getName() public method

public getName ( )

getTableNames() public method

public getTableNames ( )

hints() public method

public hints ( )

isEnum() public method

validate is ENUM.
public isEnum ( $column ) : type
$column table column
return type

requiredTemplates() public method

public requiredTemplates ( )

rules() public method

public rules ( )

validateDb() public method

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

Property Details

$baseClassSuffix public property

suffix to append to the base model, setting "Base" will result in a model named "PostBase"
public $baseClassSuffix

$baseTraits public property

base-traits
public $baseTraits

$classNames2 protected property

protected $classNames2

$createdAtColumn public property

the name of the column where the user who updated the entry is stored
public $createdAtColumn

$createdByColumn public property

the name of the column where the user who created the entry is stored
public $createdByColumn

$generateHintsFromComments public property

This indicates whether the generator should generate attribute hints by using the comments of the corresponding DB columns
public $generateHintsFromComments

$generateModelClass public property

whether to overwrite (extended) model classes, will be always created, if file does not exist
public $generateModelClass

$languageCodeColumn public property

the column name where the language code is stored
public $languageCodeColumn

$languageTableName public property

the name of the table containing the translations. {{table}} will be replaced with the value in "Table Name" field
public $languageTableName

$messageCategory public property

public $messageCategory

$removeDuplicateRelations public property

public $removeDuplicateRelations

$savedForm public property

form field for selecting and loading saved gii forms
public $savedForm

$singularEntities public property

public $singularEntities

$tableNameMap public property

key-value pairs for mapping a table-name to class-name, eg. 'prefix_FOObar' => 'FooBar'
public $tableNameMap

$tablePrefix public property

string for the table prefix, which is ignored in generated class name
public $tablePrefix

$updatedAtColumn public property

the name of the column where the user who updated the entry is stored
public $updatedAtColumn

$updatedByColumn public property

the name of the column where the user who updated the entry is stored
public $updatedByColumn

$useBlameableBehavior public property

whether or not to use BlameableBehavior
public $useBlameableBehavior

$useTimestampBehavior public property

whether or not to use TimestampBehavior
public $useTimestampBehavior

$useTranslatableBehavior public property

whether or not to use 2amigos/yii2-translateable-behavior
public $useTranslatableBehavior