Class yii\gii\generators\crud\Generator
Inheritance | yii\gii\generators\crud\Generator » yii\gii\Generator » yii\base\Model |
---|---|
Available since version | 2.0 |
Generates CRUD
Public Properties
Property | Type | Description | Defined 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
Protected Methods
Method | Description | Defined By |
---|---|---|
getClassDbDriverName() | yii\gii\generators\crud\Generator |
Property Details
Method Details
public void attributeLabels ( ) |
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. |
---|
Generates parameter tags for phpdoc
public array generateActionParamComments ( ) | ||
return | array | Parameter tags for phpdoc |
---|
Generates action parameters
public string generateActionParams ( ) |
Generates code for active field
public string generateActiveField ( $attribute ) | ||
$attribute | string |
Generates code for active search field
public string generateActiveSearchField ( $attribute ) | ||
$attribute | string |
Generates column format
public string generateColumnFormat ( $column ) | ||
$column | \yii\db\ColumnSchema |
Generates search conditions
public array generateSearchConditions ( ) |
Generates the attribute labels for the search model.
public array generateSearchLabels ( ) | ||
return | array | The generated attribute labels (name => label) |
---|
Generates validation rules for the search model.
public array generateSearchRules ( ) | ||
return | array | The generated validation rules |
---|
Generates URL parameters
public string generateUrlParams ( ) |
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. |
---|
public array getColumnNames ( ) | ||
return | array | Model column names |
---|
public string getControllerID ( ) | ||
return | string | The controller ID (without the module ID prefix) |
---|
public string getDescription ( ) | ||
return | string | The detailed description of the generator. |
---|
public string getName ( ) | ||
return | string | Name of the code generator |
---|
public string getNameAttribute ( ) |
public array getSearchAttributes ( ) | ||
return | array | Searchable attributes |
---|
Returns table schema for current model class or false if it is not an active record
public boolean|\yii\db\TableSchema getTableSchema ( ) |
public string getViewPath ( ) | ||
return | string | The controller view path |
---|
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 |
---|
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. |
---|
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 ( ) |
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 |
---|
Checks if model class is valid
public void validateModelClass ( ) |