PHP Class infoweb\cms\behaviors\ImageBehave

Inheritance: extends rico\yii2images\behaviors\ImageBehave
Exibir arquivo Open project: infoweb-internet-solutions/yii2-cms

Public Methods

Method Description
attachImage ( string $absolutePath, boolean $isMain = false, string $identifier = '' ) : boolean | Image Copies the image to the assets folder and save's it in the database.
clearCache ( ) : array | ActiveRecord[] Returns model images First image alwats must be main image
getImage ( boolean $fallbackToPlaceholder = true, mixed $placeHolderPath = null ) : array | null | ActiveRecord Returns main model image
getImageByIdentifier ( string $identifier = '', $fallbackToPlaceholder = true, $placeHolderPath = null ) : array | null | ActiveRecord Returns a model's image with a specific identifier
getImages ( $additionWhere = false, $fallbackToPlaceholder = true, $sort = ['position' => SORT_DESC] ) : array | ActiveRecord[] Returns model images First image alwats must be main image
getRemoveRequest ( null $identifier = null ) : string Url for removing images in image widget
getUploadedImageByName ( $name )
getUploadedImages ( )
removeImage ( rico\yii2images\models\Image $img ) removes concrete model's image
removeImageByIdentifier ( string $identifier = '' ) : boolean Removes an image with a specific identifier
removeImages ( ) Remove all model images
setMainImage ( $img ) Sets main image of model
uploadImage ( ) Upload and attach images
uploadImageByName ( string $name = '', boolean $isMain = false, string $identifier = '' ) Uploads and attaches an image

Private Methods

Method Description
getAlias ( ) Обновить алиасы для картинок Зачистить кэш
getAliasString ( ) : string Make string part of image's url
getImagesFinder ( $additionWhere = false ) *public function getImage() { if ($this->getModule()->className === null) { $imageQuery = Image::find(); } else { $class = $this->getModule()->className; $imageQuery = $class::find(); } $finder = $this->getImagesFinder(['isMain' => 1]); $imageQuery->where($finder); $imageQuery->orderBy(['isMain' => SORT_DESC, 'id' => SORT_ASC]);

Method Details

attachImage() public method

Copies the image to the assets folder and save's it in the database.
public attachImage ( string $absolutePath, boolean $isMain = false, string $identifier = '' ) : boolean | Image
$absolutePath string The path were the image is uploaded
$isMain boolean A flag to determine if the image is the main image
$identifier string The index that has to be set for the image in the database
return boolean | infoweb\cms\models\Image

clearCache() public method

Returns model images First image alwats must be main image
public clearCache ( ) : array | ActiveRecord[]
return array | yii\db\ActiveRecord[]

getImage() public method

Returns main model image
public getImage ( boolean $fallbackToPlaceholder = true, mixed $placeHolderPath = null ) : array | null | ActiveRecord
$fallbackToPlaceholder boolean A flag to determine if a placeholder has to be used when no image is found
$placeHolderPath mixed The alternative placeholder path
return array | null | ActiveRecord

getImageByIdentifier() public method

Returns a model's image with a specific identifier
public getImageByIdentifier ( string $identifier = '', $fallbackToPlaceholder = true, $placeHolderPath = null ) : array | null | ActiveRecord
$identifier string The identifier of the image
return array | null | ActiveRecord

getImages() public method

Returns model images First image alwats must be main image
public getImages ( $additionWhere = false, $fallbackToPlaceholder = true, $sort = ['position' => SORT_DESC] ) : array | ActiveRecord[]
return array | yii\db\ActiveRecord[]

getRemoveRequest() public method

Url for removing images in image widget
public getRemoveRequest ( null $identifier = null ) : string
$identifier null
return string

getUploadedImageByName() public method

public getUploadedImageByName ( $name )

getUploadedImages() public method

public getUploadedImages ( )

removeImage() public method

removes concrete model's image
public removeImage ( rico\yii2images\models\Image $img )
$img rico\yii2images\models\Image

removeImageByIdentifier() public method

Removes an image with a specific identifier
public removeImageByIdentifier ( string $identifier = '' ) : boolean
$identifier string The identifier of the image
return boolean

removeImages() public method

Remove all model images
public removeImages ( )

setMainImage() public method

Sets main image of model
public setMainImage ( $img )
$img

uploadImage() public method

Upload and attach images
public uploadImage ( )

uploadImageByName() public method

Uploads and attaches an image
public uploadImageByName ( string $name = '', boolean $isMain = false, string $identifier = '' )
$name string The name if the image in the uploaded files array
$isMain boolean The main image flag
$identifier string The image identifier