PHP Class ElementCode

Inheritance: extends CCodeModel
Mostrar archivo Open project: openeyes/openeyes

Public Properties

Property Type Description
$authorEmail
$authorName
$baseClass
$baseControllerClass
$controllerClass
$elementFields
$elementName Properties
$ignore
$level
$migrationPath
$modelClass
$modelPath
$tableName
$tableSchema

Public Methods

Method Description
attributeLabels ( ) : array Attribute labels.
checkColumns ( $table ) * Check that all database field names conform to PHP variable naming rules For example mysql allows field name like "2011aa", but PHP does not allow variables like "$model->2011aa"
confirmed ( CCodeFile $file ) : boolean Checks to determine whether file should be saved.
generateActiveField ( string $modelClass, string $column ) : string Generates an appropriate input field for _form view.
generateActiveLabel ( string $modelClass, string $column ) : string Generates an appropriate label for a field of the element.
generateLabels ( CDbTableSchema $table ) : array Generates labels for fields of the table.
generateRules ( CDbTableSchema $table ) : array Generates rules for the table.
getTableSchema ( $tableName ) * Gets schema for passed tableName
init ( ) Runs on object initiation.
prepare ( ) * Run on form submission by preview or generate buttons. Generates the list of files and code
renderResults ( ) : string Write results and run migration scripts.
requiredTemplates ( ) : array List of templates that must be present.
resetGenerator ( ) * Resets all session variables to allow restart in case of error
resetTimeStamps ( ) Reset the time stamps.
rules ( ) Validation rules.
save ( ) : boolean Saves the generated views code into files NB Ensure _www has write permissions for elements directory.
successMessage ( ) * Returns a success message
validateBaseClass ( $attribute, array $params ) Validation method for base class.
validateElementFields ( $attribute, array $params ) Validation method for elementFields.
validateModelClass ( $attribute, array $params ) Validation method for model class and associated table.
validateModelPath ( $attribute, array $params ) Validation method for model path.
validateTableName ( $attribute, array $params ) Validation method for table name and model class.

Protected Methods

Method Description
createTimeStamp ( $description ) Creates time stamp in format expected for ./yiic migrate Stores in a session variable, otherwise time stamp changes on each second call.
generateClassName ( $tableName ) * Generates Yii style class name from table name
generateControllerName ( $modelClass ) * Generates Yii style controller name from class name
generateMigrationName ( $description, $tableName ) Generates a time stamped migration file name in format expected by ./yiic migrate.

Method Details

attributeLabels() public method

Attribute labels.
public attributeLabels ( ) : array
return array

checkColumns() public method

* Check that all database field names conform to PHP variable naming rules For example mysql allows field name like "2011aa", but PHP does not allow variables like "$model->2011aa"
public checkColumns ( $table )
$table the table schema object

confirmed() public method

Checks to determine whether file should be saved.
public confirmed ( CCodeFile $file ) : boolean
$file CCodeFile The file to be saved
return boolean Whether the code file should be saved

createTimeStamp() protected method

Creates time stamp in format expected for ./yiic migrate Stores in a session variable, otherwise time stamp changes on each second call.
protected createTimeStamp ( $description )

generateActiveField() public method

Generates an appropriate input field for _form view.
public generateActiveField ( string $modelClass, string $column ) : string
$modelClass string Name of the element's model class
$column string Name of a table colum
return string A form input element

generateActiveLabel() public method

Generates an appropriate label for a field of the element.
public generateActiveLabel ( string $modelClass, string $column ) : string
$modelClass string Name of the element's model class
$column string Name of a table colum
return string A label

generateClassName() protected method

* Generates Yii style class name from table name
protected generateClassName ( $tableName )
$tableName Name of the table

generateControllerName() protected method

* Generates Yii style controller name from class name
protected generateControllerName ( $modelClass )
$modelClass Name of the table

generateLabels() public method

Generates labels for fields of the table.
public generateLabels ( CDbTableSchema $table ) : array
$table CDbTableSchema A table
return array Array containing the labels

generateMigrationName() protected method

Generates a time stamped migration file name in format expected by ./yiic migrate.
protected generateMigrationName ( $description, $tableName )

generateRules() public method

Generates rules for the table.
public generateRules ( CDbTableSchema $table ) : array
$table CDbTableSchema A table
return array Array of rules

getTableSchema() public method

* Gets schema for passed tableName
public getTableSchema ( $tableName )
$tableName Name of table

init() public method

Runs on object initiation.
public init ( )

prepare() public method

* Run on form submission by preview or generate buttons. Generates the list of files and code
public prepare ( )

renderResults() public method

Write results and run migration scripts.
public renderResults ( ) : string
return string the code generation result log.

requiredTemplates() public method

List of templates that must be present.
public requiredTemplates ( ) : array
return array

resetGenerator() public method

* Resets all session variables to allow restart in case of error
public resetGenerator ( )

resetTimeStamps() public method

Reset the time stamps.
public resetTimeStamps ( )

rules() public method

Validation rules.
public rules ( )

save() public method

Saves the generated views code into files NB Ensure _www has write permissions for elements directory.
public save ( ) : boolean
return boolean True if save is successful

successMessage() public method

* Returns a success message
public successMessage ( )

validateBaseClass() public method

Validation method for base class.
public validateBaseClass ( $attribute, array $params )
$params array Array of parameters

validateElementFields() public method

Validation method for elementFields.
public validateElementFields ( $attribute, array $params )
$params array Array of parameters

validateModelClass() public method

Validation method for model class and associated table.
public validateModelClass ( $attribute, array $params )
$params array Array of parameters

validateModelPath() public method

Validation method for model path.
public validateModelPath ( $attribute, array $params )
$params array Array of parameters

validateTableName() public method

Validation method for table name and model class.
public validateTableName ( $attribute, array $params )
$params array Array of parameters

Property Details

$authorEmail public_oe property

public $authorEmail

$authorName public_oe property

public $authorName

$baseClass public_oe property

public $baseClass

$baseControllerClass public_oe property

public $baseControllerClass

$controllerClass public_oe property

public $controllerClass

$elementFields public_oe property

public $elementFields

$elementName public_oe property

Properties
public $elementName

$ignore public_oe property

public $ignore

$level public_oe property

public $level

$migrationPath public_oe property

public $migrationPath

$modelClass public_oe property

public $modelClass

$modelPath public_oe property

public $modelPath

$tableName public_oe property

public $tableName

$tableSchema public_oe property

public $tableSchema