PHP Class yupe\components\behaviors\FileUploadBehavior

Inheritance: extends CActiveRecordBehavio\CActiveRecordBehavior
Show file Open project: yupe/yupe Class Usage Examples

Public Properties

Property Type Description
$attributeName attribute to store name of the uploaded file.
$deleteFileKey string
$fileInstanceName the name of the file input field, used to get instance by name. Optional. If not set get instance by model attribute will be used.
$fileName callback function to generate filename. Optional. If not set, default implementation will be used.
$maxSize maximum file size.
$minSize minimum file size.
$requiredOn scenarios when file upload is required.
$scenarios allowed scenarios when this behavior will be used.
$types allowed file types.
$uploadPath path of the upload directory.

Protected Properties

Property Type Description
$uploadManager yupe\components\UploadManager

Public Methods

Method Description
addFileInstanceName ( $name )
attach ( CComponent $owner )
beforeDelete ( CEvent $event )
beforeSave ( CModelEvent $event ) : boolean
beforeValidate ( CModelEvent $event )
checkScenario ( ) : boolean Checks whether there is a current scenario in allowed scenarios.
generateFilename ( ) : string
getFilePath ( ) : mixed
getFileUrl ( ) : string
getUploadPath ( ) : string
saveFile ( ) : void. Save new uploaded file to disk and set model attribute.

Protected Methods

Method Description
getUploadedFileInstance ( ) : CUploadedFile
removeFile ( ) : void. Remove previous uploaded file.

Method Details

addFileInstanceName() public method

public addFileInstanceName ( $name )
$name string the name of the file input field.

attach() public method

public attach ( CComponent $owner )
$owner CComponent

beforeDelete() public method

public beforeDelete ( CEvent $event )
$event CEvent

beforeSave() public method

public beforeSave ( CModelEvent $event ) : boolean
$event CModelEvent
return boolean

beforeValidate() public method

public beforeValidate ( CModelEvent $event )
$event CModelEvent

checkScenario() public method

Checks whether there is a current scenario in allowed scenarios.
public checkScenario ( ) : boolean
return boolean true if current scenario is allowed.

generateFilename() public method

public generateFilename ( ) : string
return string generated file name.

getFilePath() public method

public getFilePath ( ) : mixed
return mixed

getFileUrl() public method

public getFileUrl ( ) : string
return string url to uploaded file.

getUploadPath() public method

public getUploadPath ( ) : string
return string path of the upload directory.

getUploadedFileInstance() protected method

protected getUploadedFileInstance ( ) : CUploadedFile
return CUploadedFile

removeFile() protected method

Remove previous uploaded file.
protected removeFile ( ) : void.
return void.

saveFile() public method

Save new uploaded file to disk and set model attribute.
public saveFile ( ) : void.
return void.

Property Details

$attributeName public property

attribute to store name of the uploaded file.
public $attributeName

$deleteFileKey public property

public string $deleteFileKey
return string

$fileInstanceName public property

the name of the file input field, used to get instance by name. Optional. If not set get instance by model attribute will be used.
public $fileInstanceName

$fileName public property

callback function to generate filename. Optional. If not set, default implementation will be used.
public $fileName

$maxSize public property

maximum file size.
public $maxSize

$minSize public property

minimum file size.
public $minSize

$requiredOn public property

scenarios when file upload is required.
public $requiredOn

$scenarios public property

allowed scenarios when this behavior will be used.
public $scenarios

$types public property

allowed file types.
public $types

$uploadManager protected property

protected UploadManager,yupe\components $uploadManager
return yupe\components\UploadManager

$uploadPath public property

path of the upload directory.
public $uploadPath