PHP Class yii\gii\CodeFile

Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\Object
Datei anzeigen Open project: yiisoft/yii2-gii Class Usage Examples

Public Properties

Property Type Description
$content the newly generated code content
$id an ID that uniquely identifies this code file.
$operation the operation to be performed. This can be [[OP_CREATE]], [[OP_OVERWRITE]] or [[OP_SKIP]].
$path the file path that the new code should be saved to.

Public Methods

Method Description
__construct ( string $path, string $content, array $config = [] ) Constructor.
diff ( ) : boolean | string Returns diff or false if it cannot be calculated
getRelativePath ( ) : string
getType ( ) : string
preview ( ) : boolean | string Returns preview or false if it cannot be rendered
save ( ) : string | boolean Saves the code into the file specified by [[path]].

Private Methods

Method Description
renderDiff ( mixed $lines1, mixed $lines2 ) : string Renders diff between two sets of lines

Method Details

__construct() public method

Constructor.
public __construct ( string $path, string $content, array $config = [] )
$path string the file path that the new code should be saved to.
$content string the newly generated code content.
$config array name-value pairs that will be used to initialize the object properties

diff() public method

Returns diff or false if it cannot be calculated
public diff ( ) : boolean | string
return boolean | string

getRelativePath() public method

public getRelativePath ( ) : string
return string the code file path relative to the application base path.

getType() public method

public getType ( ) : string
return string the code file extension (e.g. php, txt)

preview() public method

Returns preview or false if it cannot be rendered
public preview ( ) : boolean | string
return boolean | string

save() public method

Saves the code into the file specified by [[path]].
public save ( ) : string | boolean
return string | boolean the error occurred while saving the code file, or true if no error.

Property Details

$content public_oe property

the newly generated code content
public $content

$id public_oe property

an ID that uniquely identifies this code file.
public $id

$operation public_oe property

the operation to be performed. This can be [[OP_CREATE]], [[OP_OVERWRITE]] or [[OP_SKIP]].
public $operation

$path public_oe property

the file path that the new code should be saved to.
public $path