Class yii\gii\generators\module\Generator

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

This generator will generate the skeleton code needed by a module.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$enableI18N boolean Whether the strings will be generated using Yii::t() or normal strings. yii\gii\Generator
$messageCategory string The message category used by Yii::t() when $enableI18N is true. yii\gii\Generator
$moduleClass yii\gii\generators\module\Generator
$moduleID yii\gii\generators\module\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

Public Methods

Hide inherited methods

MethodDescriptionDefined By
attributeLabels() yii\gii\generators\module\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\module\Generator
generateString() Generates a string depending on enableI18N property yii\gii\Generator
getControllerNamespace() yii\gii\generators\module\Generator
getDescription() yii\gii\generators\module\Generator
getModulePath() yii\gii\generators\module\Generator
getName() yii\gii\generators\module\Generator
getStickyDataFile() yii\gii\Generator
getTemplatePath() yii\gii\Generator
hints() Returns the list of hint messages. yii\gii\generators\module\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\module\Generator
rules() yii\gii\generators\module\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\Generator
successMessage() Returns the message to be displayed when the newly generated code is saved successfully. yii\gii\generators\module\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
validateModuleClass() Validates $moduleClass to make sure it is a fully qualified class name. yii\gii\generators\module\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

$moduleClass public property
public $moduleClass null
$moduleID public property
public $moduleID 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.

getControllerNamespace() public method

public string getControllerNamespace ( )
return string

The controller namespace of the module.

getDescription() public method

public string getDescription ( )
return string

The detailed description of the generator.

getModulePath() public method

public boolean getModulePath ( )
return boolean

The directory that contains the module class

getName() public method

public string getName ( )
return string

Name of the code generator

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\module\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 ( )
successMessage() public method

Returns the message to be displayed when the newly generated code is saved successfully.

Child classes may override this method to customize the message.

public string successMessage ( )
return string

The message to be displayed when the newly generated code is saved successfully.

validateModuleClass() public method

Validates $moduleClass to make sure it is a fully qualified class name.

public void validateModuleClass ( )