Class schmunk42\giiant\generators\model\Generator

Inheritanceschmunk42\giiant\generators\model\Generator » yii\gii\generators\model\Generator
Available since version0.0.1

This generator will generate one or multiple ActiveRecord classes for the specified database table.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$baseClassSuffix string Suffix to append to the base model, setting "Base" will result in a model named "PostBase" schmunk42\giiant\generators\model\Generator
$baseTraits string Base-traits schmunk42\giiant\generators\model\Generator
$createdAtColumn string The name of the column where the user who updated the entry is stored schmunk42\giiant\generators\model\Generator
$createdByColumn string The name of the column where the user who created the entry is stored schmunk42\giiant\generators\model\Generator
$generateHintsFromComments bool This indicates whether the generator should generate attribute hints by using the comments of the corresponding DB columns schmunk42\giiant\generators\model\Generator
$generateModelClass bool Whether to overwrite (extended) model classes, will be always created, if file does not exist schmunk42\giiant\generators\model\Generator
$languageCodeColumn string The column name where the language code is stored schmunk42\giiant\generators\model\Generator
$languageTableName string The name of the table containing the translations. schmunk42\giiant\generators\model\Generator
$messageCategory schmunk42\giiant\generators\model\Generator
$removeDuplicateRelations schmunk42\giiant\generators\model\Generator
$savedForm string Form field for selecting and loading saved gii forms schmunk42\giiant\generators\model\Generator
$singularEntities schmunk42\giiant\generators\model\Generator
$tableNameMap array Key-value pairs for mapping a table-name to class-name, eg. schmunk42\giiant\generators\model\Generator
$tablePrefix null String for the table prefix, which is ignored in generated class name schmunk42\giiant\generators\model\Generator
$updatedAtColumn string The name of the column where the user who updated the entry is stored schmunk42\giiant\generators\model\Generator
$updatedByColumn string The name of the column where the user who updated the entry is stored schmunk42\giiant\generators\model\Generator
$useBlameableBehavior bool Whether or not to use BlameableBehavior schmunk42\giiant\generators\model\Generator
$useTimestampBehavior bool Whether or not to use TimestampBehavior schmunk42\giiant\generators\model\Generator
$useTranslatableBehavior bool Whether or not to use 2amigos/yii2-translateable-behavior schmunk42\giiant\generators\model\Generator

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$classNames2 schmunk42\giiant\generators\model\Generator

Property Details

$baseClassSuffix public property

Suffix to append to the base model, setting "Base" will result in a model named "PostBase"

$baseTraits public property

Base-traits

public string $baseTraits null
$classNames2 protected property
protected $classNames2 null
$createdAtColumn public property

The name of the column where the user who updated the entry is stored

public string $createdAtColumn 'created_at'
$createdByColumn public property

The name of the column where the user who created the entry is stored

public string $createdByColumn 'created_by'
$generateHintsFromComments public property

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

public bool $generateHintsFromComments true
$generateModelClass public property

Whether to overwrite (extended) model classes, will be always created, if file does not exist

public bool $generateModelClass false
$languageCodeColumn public property

The column name where the language code is stored

public string $languageCodeColumn 'language'
$languageTableName public property

The name of the table containing the translations. {{table}} will be replaced with the value in

        "Table Name" field
public string $languageTableName '{{table}}_lang'
$messageCategory public property
public $messageCategory 'models'
$removeDuplicateRelations public property
$savedForm public property

Form field for selecting and loading saved gii forms

public string $savedForm null
$singularEntities public property
public $singularEntities false
$tableNameMap public property

Key-value pairs for mapping a table-name to class-name, eg. 'prefix_FOObar' => 'FooBar'

public array $tableNameMap = []
$tablePrefix public property

String for the table prefix, which is ignored in generated class name

public null $tablePrefix null
$updatedAtColumn public property

The name of the column where the user who updated the entry is stored

public string $updatedAtColumn 'updated_at'
$updatedByColumn public property

The name of the column where the user who updated the entry is stored

public string $updatedByColumn 'updated_by'
$useBlameableBehavior public property

Whether or not to use BlameableBehavior

public bool $useBlameableBehavior true
$useTimestampBehavior public property

Whether or not to use TimestampBehavior

public bool $useTimestampBehavior true
$useTranslatableBehavior public property

Whether or not to use 2amigos/yii2-translateable-behavior

public bool $useTranslatableBehavior true

Method Details

attributeLabels() public method

{@inheritdoc}

public void attributeLabels ( )
extractTranslations() protected method

protected array extractTranslations ( $tableName, $relations )
$tableName
$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 array formAttributes ( )
generate() public method

{@inheritdoc}

public void generate ( )
generateBlameable() protected method

protected string[] generateBlameable ( $table )
$table \yii\db\TableSchema

The table schema

generateClassName() public method

Generates a class name from the specified table name.

public string generateClassName ( $tableName, $useSchemaName null )
$tableName string

The table name (which may contain schema prefix)

$useSchemaName
return string

The generated class name

generateHints() public method

Generates the attribute hints for the specified table.

public array generateHints ( $table )
$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

{@inheritdoc}

public void generateRelationName ( $relations, $table, $key, $multiple )
$relations
$table
$key
$multiple
generateRelations() protected method

protected void generateRelations ( )
generateRules() public method

Generates validation rules for the specified table and add enum value validation.

public array generateRules ( $table )
$table \yii\db\TableSchema

The table schema

return array

The generated validation rules

generateTimestamp() protected method

protected string[] generateTimestamp ( $table )
$table \yii\db\TableSchema

The table schema

getDbConnection() protected method

protected \yii\db\Connection getDbConnection ( )
return \yii\db\Connection

The DB connection from the DI container or as application component specified by \schmunk42\giiant\generators\model\db

getDescription() public method

{@inheritdoc}

public void getDescription ( )
getEnum() public method

Prepare ENUM field values.

public array getEnum ( $columns )
$columns array
getName() public method

{@inheritdoc}

public void getName ( )
getTableNames() public method

{@inheritdoc}

public void getTableNames ( )
hints() public method

{@inheritdoc}

public void hints ( )
isEnum() public method

Validate is ENUM.

public \schmunk42\giiant\generators\model\type isEnum ( $column )
$column

Table column

requiredTemplates() public method

{@inheritdoc}

public void requiredTemplates ( )
rules() public method

{@inheritdoc}

public void rules ( )
validateDb() public method

Validates the \schmunk42\giiant\generators\model\db attribute.

public void validateDb ( )