Class yii\gii\generators\extension\Generator

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

This generator will generate the skeleton files needed by an extension.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
attributeLabels() yii\gii\generators\extension\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\extension\Generator
generateString() Generates a string depending on enableI18N property yii\gii\Generator
getDescription() yii\gii\generators\extension\Generator
getKeywordsArrayJson() yii\gii\generators\extension\Generator
getName() yii\gii\generators\extension\Generator
getOutputPath() yii\gii\generators\extension\Generator
getStickyDataFile() yii\gii\Generator
getTemplatePath() yii\gii\Generator
hints() Returns the list of hint messages. yii\gii\generators\extension\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
optsLicense() yii\gii\generators\extension\Generator
optsType() yii\gii\generators\extension\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\extension\Generator
rules() yii\gii\generators\extension\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\extension\Generator
successMessage() Returns the message to be displayed when the newly generated code is saved successfully. yii\gii\generators\extension\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
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

$authorEmail public property
public $authorEmail null
$authorName public property
public $authorName null
$description public property
public $description null
$keywords public property
public $keywords "yii2,extension"
$license public property
public $license null
$namespace public property
public $namespace null
$outputPath public property
public $outputPath "@app/runtime/tmp-extensions"
$packageName public property
public $packageName "yii2-"
$title public property
public $title null
$type public property
public $type "yii2-extension"
$vendorName public property
public $vendorName 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.

getDescription() public method

public string getDescription ( )
return string

The detailed description of the generator.

getKeywordsArrayJson() public method

public string getKeywordsArrayJson ( )
return string

A json encoded array with the given keywords

getName() public method

public string getName ( )
return string

Name of the code generator

getOutputPath() public method

public boolean getOutputPath ( )
return boolean

The directory that contains the module class

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

optsLicense() public method

public array optsLicense ( )
return array

Options for license drop-down

optsType() public method

public array optsType ( )
return array

Options for type drop-down

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\extension\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

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.