Class lispa\amos\attachments\behaviors\FileBehavior

Inheritancelispa\amos\attachments\behaviors\FileBehavior » yii\base\Behavior » yii\base\Object
Implementsyii\base\Configurable
Uses Traitslispa\amos\attachments\FileModuleTrait

Class FileBehavior

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Parse file behaviors and find for the choosed attribute for hasOne or hasMultiple files relation lispa\amos\attachments\behaviors\FileBehavior
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Setter is an override tool for validation lispa\amos\attachments\behaviors\FileBehavior
__unset() Sets an object property to null. yii\base\Object
attach() Attaches the behavior object to the component. yii\base\Behavior
canGetProperty() Add files attributes as avaiable property for Getter lispa\amos\attachments\behaviors\FileBehavior
canSetProperty() Add files attributes as avaiable property for Setter lispa\amos\attachments\behaviors\FileBehavior
className() Returns the fully qualified name of this class. yii\base\Object
deleteUploads() lispa\amos\attachments\behaviors\FileBehavior
detach() Detaches the behavior object from the component. yii\base\Behavior
evalAttributes() When update save files before the validation lispa\amos\attachments\behaviors\FileBehavior
events() Declares event handlers for the $owner's events. lispa\amos\attachments\behaviors\FileBehavior
getFileAttributes() Return array of attributes which may contain files lispa\amos\attachments\behaviors\FileBehavior
getFileCount() lispa\amos\attachments\behaviors\FileBehavior
getFileValidator() lispa\amos\attachments\behaviors\FileBehavior
getFileValidators() Check if owner model has file validator lispa\amos\attachments\behaviors\FileBehavior
getFiles() lispa\amos\attachments\behaviors\FileBehavior
getFilesByAttributeName() DEPRECATED lispa\amos\attachments\behaviors\FileBehavior
getFilesQuery() lispa\amos\attachments\behaviors\FileBehavior
getInitialPreviewByAttributeName() lispa\amos\attachments\behaviors\FileBehavior
getInitialPreviewConfigByAttributeName() lispa\amos\attachments\behaviors\FileBehavior
getSingleFileByAttributeName() DEPRECATED lispa\amos\attachments\behaviors\FileBehavior
getStatsToolbar() lispa\amos\attachments\behaviors\FileBehavior
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasMultipleFiles() lispa\amos\attachments\behaviors\FileBehavior
hasOneFile() lispa\amos\attachments\behaviors\FileBehavior
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object
saveUploads() Iterate files and save by attribute lispa\amos\attachments\behaviors\FileBehavior
unevalAttributes() Unset attributes from override lispa\amos\attachments\behaviors\FileBehavior

Property Details

$fileAttributes public read-only property
$fileCount public read-only property
$files public read-only property
public lispa\amos\attachments\models\File[] getFiles ( $andWhere '' )
$filesByAttributeName public read-only property
public void getFilesByAttributeName ( $attribute 'file', $sort 'id' )
$filesQuery public read-only property
public yii\db\ActiveQuery getFilesQuery ( $andWhere '' )
$initialPreviewByAttributeName public read-only property
public array getInitialPreviewByAttributeName ( $attribute 'file', $size null )
$initialPreviewConfigByAttributeName public read-only property
public array getInitialPreviewConfigByAttributeName ( $attribute 'file' )
$permissions public property
public array $permissions = []
$rules public property
public array $rules = []
$singleFileByAttributeName public read-only property
public void getSingleFileByAttributeName ( $attribute 'file', $sort 'id' )
$statsToolbar public read-only property
public mixed getStatsToolbar ( )

Method Details

__get() public method

Parse file behaviors and find for the choosed attribute for hasOne or hasMultiple files relation

public array|mixed __get ( $name )
$name string
throws yii\base\UnknownPropertyException
__set() public method

Setter is an override tool for validation

public void __set ( $name, $value )
$name
$value
canGetProperty() public method

Add files attributes as avaiable property for Getter

public boolean canGetProperty ( $name, $checkVars true )
$name
$checkVars
canSetProperty() public method

Add files attributes as avaiable property for Setter

public boolean canSetProperty ( $name, $checkVars true )
$name
$checkVars
cropImage() protected method

protected void cropImage ( yii\web\UploadedFile $file, $data )
$file
$data
deleteUploads() public method

public void deleteUploads ( $event )
$event
evalAttributes() public method

When update save files before the validation

public boolean|void evalAttributes ( $event )
$event
events() public method

Declares event handlers for the $owner's events.

Child classes may override this method to declare what PHP callbacks should be attached to the events of the $owner component.

The callbacks will be attached to the $owner's events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component.

The callbacks can be any of the following:

  • method in this behavior: 'handleClick', equivalent to [$this, 'handleClick']
  • object method: [$object, 'handleClick']
  • static method: ['Page', 'handleClick']
  • anonymous function: function ($event) { ... }

The following is an example:

[
    Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate',
    Model::EVENT_AFTER_VALIDATE => 'myAfterValidate',
]
public array events ( )
return array

Events (array keys) and the corresponding event handler methods (array values).

getFileAttributes() public method

Return array of attributes which may contain files

public array getFileAttributes ( )
getFileCount() public method

public integer getFileCount ( )
throws Exception
getFileValidator() public method

public boolean|mixed|yii\validators\FileValidator|yii\validators\Validator getFileValidator ( $attributeName )
$attributeName
getFileValidators() public method

Check if owner model has file validator

public yii\validators\Validator[] getFileValidators ( $validators )
$validators
getFiles() public method

public lispa\amos\attachments\models\File[] getFiles ( $andWhere '' )
$andWhere string
getFilesByAttributeName() public method

DEPRECATED

public void getFilesByAttributeName ( $attribute 'file', $sort 'id' )
$attribute
$sort
getFilesQuery() public method

public yii\db\ActiveQuery getFilesQuery ( $andWhere '' )
$andWhere string
getInitialPreviewByAttributeName() public method

public array getInitialPreviewByAttributeName ( $attribute 'file', $size null )
$attribute string
$size
getInitialPreviewConfigByAttributeName() public method

public array getInitialPreviewConfigByAttributeName ( $attribute 'file' )
$attribute string
getSingleFileByAttributeName() public method

DEPRECATED

public void getSingleFileByAttributeName ( $attribute 'file', $sort 'id' )
$attribute
$sort
getStatsToolbar() public method

public mixed getStatsToolbar ( )
hasMultipleFiles() public method

public yii\db\ActiveQuery hasMultipleFiles ( $attribute 'file', $sort 'id' )
$attribute string
$sort string
hasOneFile() public method

public yii\db\ActiveQuery hasOneFile ( $attribute 'file', $sort 'id' )
$attribute string
$sort string
saveAttributeUploads() protected method

protected void saveAttributeUploads ( $attribute )
$attribute
saveUploads() public method

Iterate files and save by attribute

public void saveUploads ( $event )
$event
unevalAttributes() public method

Unset attributes from override

public boolean unevalAttributes ( )