Class yii\gii\generators\crud\Generator

Inheritanceyii\gii\generators\crud\Generator » yii\gii\Generator » yii\base\Model
Available since version2.0

Generates CRUD

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$baseControllerClass yii\gii\generators\crud\Generator
$controllerClass yii\gii\generators\crud\Generator
$enableI18N boolean Whether the strings will be generated using Yii::t() or normal strings. yii\gii\Generator
$enablePjax boolean Whether to wrap the GridView or ListView widget with the yii\widgets\Pjax widget yii\gii\generators\crud\Generator
$indexWidgetType yii\gii\generators\crud\Generator
$messageCategory string The message category used by Yii::t() when $enableI18N is true. yii\gii\Generator
$modelClass yii\gii\generators\crud\Generator
$searchModelClass yii\gii\generators\crud\Generator
$template string The name of the code template that the user has selected. yii\gii\Generator
$templates array A list of available code templates. yii\gii\Generator
$viewPath yii\gii\generators\crud\Generator

Public Methods

Hide inherited methods

MethodDescriptionDefined By
attributeLabels() yii\gii\generators\crud\Generator
autoCompleteData() Returns the list of auto complete values. yii\gii\Generator
defaultTemplate() Returns the root path to the default code template files. yii\gii\Generator
formView() Returns the view file for the input form of the generator. yii\gii\Generator
generate() Generates the code based on the current user input and the specified code template files. yii\gii\generators\crud\Generator
generateActionParamComments() Generates parameter tags for phpdoc yii\gii\generators\crud\Generator
generateActionParams() Generates action parameters yii\gii\generators\crud\Generator
generateActiveField() Generates code for active field yii\gii\generators\crud\Generator
generateActiveSearchField() Generates code for active search field yii\gii\generators\crud\Generator
generateColumnFormat() Generates column format yii\gii\generators\crud\Generator
generateSearchConditions() Generates search conditions yii\gii\generators\crud\Generator
generateSearchLabels() Generates the attribute labels for the search model. yii\gii\generators\crud\Generator
generateSearchRules() Generates validation rules for the search model. yii\gii\generators\crud\Generator
generateString() Generates a string depending on enableI18N property yii\gii\Generator
generateUrlParams() Generates URL parameters yii\gii\generators\crud\Generator
getColumnNames() yii\gii\generators\crud\Generator
getControllerID() yii\gii\generators\crud\Generator
getDescription() yii\gii\generators\crud\Generator
getName() yii\gii\generators\crud\Generator
getNameAttribute() yii\gii\generators\crud\Generator
getSearchAttributes() yii\gii\generators\crud\Generator
getStickyDataFile() yii\gii\Generator
getTableSchema() Returns table schema for current model class or false if it is not an active record yii\gii\generators\crud\Generator
getTemplatePath() yii\gii\Generator
getViewPath() yii\gii\generators\crud\Generator
hints() Returns the list of hint messages. yii\gii\generators\crud\Generator
init() yii\gii\Generator
isReservedKeyword() yii\gii\Generator
loadStickyAttributes() Loads sticky attributes from an internal file and populates them into the generator. yii\gii\Generator
render() Generates code using the specified code template and parameters. yii\gii\Generator
requiredTemplates() Returns a list of code template files that are required. yii\gii\generators\crud\Generator
rules() yii\gii\generators\crud\Generator
save() Saves the generated code into files. yii\gii\Generator
saveStickyAttributes() Saves sticky attributes into an internal file. yii\gii\Generator
stickyAttributes() Returns the list of sticky attributes. yii\gii\generators\crud\Generator
successMessage() Returns the message to be displayed when the newly generated code is saved successfully. yii\gii\Generator
validateClass() An inline validator that checks if the attribute value refers to an existing class name. yii\gii\Generator
validateMessageCategory() Checks if message category is not empty when I18N is enabled. yii\gii\Generator
validateModelClass() Checks if model class is valid yii\gii\generators\crud\Generator
validateNewClass() An inline validator that checks if the attribute value refers to a valid namespaced class name. yii\gii\Generator
validateTemplate() Validates the template selection. yii\gii\Generator

Property Details

$baseControllerClass public property
public $baseControllerClass 'yii\web\Controller'
$controllerClass public property
public $controllerClass null
$enablePjax public property (available since version 2.0.5)

Whether to wrap the GridView or ListView widget with the yii\widgets\Pjax widget

public boolean $enablePjax false
$indexWidgetType public property
public $indexWidgetType 'grid'
$modelClass public property
public $modelClass null
$searchModelClass public property
public $searchModelClass ''
$viewPath public property
public $viewPath null

Method Details

attributeLabels() public method

public void attributeLabels ( )
generate() public method

Generates the code based on the current user input and the specified code template files.

This is the main method that child classes should implement. Please refer to yii\gii\generators\controller\Generator::generate() as an example on how to implement this method.

public yii\gii\CodeFile[] generate ( )
return yii\gii\CodeFile[]

A list of code files to be created.

generateActionParamComments() public method

Generates parameter tags for phpdoc

public array generateActionParamComments ( )
return array

Parameter tags for phpdoc

generateActionParams() public method

Generates action parameters

public string generateActionParams ( )
generateActiveField() public method

Generates code for active field

public string generateActiveField ( $attribute )
$attribute string
generateActiveSearchField() public method

Generates code for active search field

public string generateActiveSearchField ( $attribute )
$attribute string
generateColumnFormat() public method

Generates column format

public string generateColumnFormat ( $column )
$column \yii\db\ColumnSchema
generateSearchConditions() public method

Generates search conditions

public array generateSearchConditions ( )
generateSearchLabels() public method

Generates the attribute labels for the search model.

public array generateSearchLabels ( )
return array

The generated attribute labels (name => label)

generateSearchRules() public method

Generates validation rules for the search model.

public array generateSearchRules ( )
return array

The generated validation rules

generateUrlParams() public method

Generates URL parameters

public string generateUrlParams ( )
getClassDbDriverName() protected method (available since version 2.0.6)

protected string|null getClassDbDriverName ( )
return string|null

Driver name of modelClass db connection. In case db is not instance of \yii\db\Connection null will be returned.

getColumnNames() public method

public array getColumnNames ( )
return array

Model column names

getControllerID() public method

public string getControllerID ( )
return string

The controller ID (without the module ID prefix)

getDescription() public method

public string getDescription ( )
return string

The detailed description of the generator.

getName() public method

public string getName ( )
return string

Name of the code generator

getNameAttribute() public method

public string getNameAttribute ( )
getSearchAttributes() public method

public array getSearchAttributes ( )
return array

Searchable attributes

getTableSchema() public method

Returns table schema for current model class or false if it is not an active record

public boolean|\yii\db\TableSchema getTableSchema ( )
getViewPath() public method

public string getViewPath ( )
return string

The controller view path

hints() public method

Returns the list of hint messages.

The array keys are the attribute names, and the array values are the corresponding hint messages. Hint messages will be displayed to end users when they are filling the form for the generator.

public array hints ( )
return array

The list of hint messages

requiredTemplates() public method

Returns a list of code template files that are required.

Derived classes usually should override this method if they require the existence of certain template files.

public array requiredTemplates ( )
return array

List of code template files that are required. They should be file paths relative to \yii\gii\generators\crud\templatePath.

rules() public method

Child classes should override this method like the following so that the parent rules are included:

return array_merge(parent::rules(), [
    ...rules for the child class...
]);
public void rules ( )
stickyAttributes() public method

Returns the list of sticky attributes.

A sticky attribute will remember its value and will initialize the attribute with this value when the generator is restarted.

public array stickyAttributes ( )
return array

List of sticky attributes

validateModelClass() public method

Checks if model class is valid

public void validateModelClass ( )