Constants

PUBLIC_PATH

PUBLIC_PATH

UPLOADS_PATH

UPLOADS_PATH

GETPATH

GETPATH

FROM_PUBLIC

FROM_PUBLIC

FROM_ROOT

FROM_ROOT

DEFAULT_FILTER

DEFAULT_FILTER

IMAGES_PATH

IMAGES_PATH

ORIGINAL

ORIGINAL

BIG_THUMB

BIG_THUMB

SMALL_THUMB

SMALL_THUMB

EXTRA_SMALL_THUMB

EXTRA_SMALL_THUMB

B_THUMB_WIDTH

B_THUMB_WIDTH

B_THUMB_HEIGHT

B_THUMB_HEIGHT

S_THUMB_WIDTH

S_THUMB_WIDTH

S_THUMB_HEIGHT

S_THUMB_HEIGHT

XS_THUMB_WIDTH

XS_THUMB_WIDTH

XS_THUMB_HEIGHT

XS_THUMB_HEIGHT

Properties

$sm

$sm : \Zend\ServiceManager\ServiceLocatorInterface

Type

\Zend\ServiceManager\ServiceLocatorInterface

Methods

__construct()

__construct(\Zend\ServiceManager\ServiceLocatorInterface  $sm) 

Construct

Parameters

\Zend\ServiceManager\ServiceLocatorInterface $sm

prepareDir()

prepareDir(  $path, integer  $mode = 509) : boolean

Creates all directories that don't exist in a given path

Parameters

$path
integer $mode

Throws

\Exception

Returns

boolean

getFullUrl()

getFullUrl(  $urlPart) : string

Generates full url from an url part e.g. You give "/module/controller/action/id", it returns "www.test.com/module/controller/action/id"

Parameters

$urlPart

Returns

string

deleteFile()

deleteFile(  $fileId) 

Deletes a file using sub-methods for deleting File entity and ObjectFile entity

Parameters

$fileId

deleteFileEntity()

deleteFileEntity(\Media\Entity\File  $file) 

Deletes File entity

Parameters

\Media\Entity\File $file

deleteObjectFileEntity()

deleteObjectFileEntity(\Media\Entity\File  $file) 

Deletes ObjectFile entity

Parameters

\Media\Entity\File $file

createFile()

createFile(\Media\Form\FileUpload  $form,   $object) : \Media\Entity\File

Creates file using sub-methods to write file and to associate it with an object

Parameters

\Media\Form\FileUpload $form
$object

Returns

\Media\Entity\File

associateFileWithObject()

associateFileWithObject(\Media\Entity\File  $file,   $object) 

Makes an association between a created file and an entity. It means, that the object file be the owner of the file

Parameters

\Media\Entity\File $file
$object

writeFile()

writeFile(\Media\Form\FileUpload  $form) : \Media\Entity\File

Writes file to a DB and moves it to an appropriate path

Parameters

\Media\Form\FileUpload $form

Throws

\Exception

Returns

\Media\Entity\File

generateFileUploadForm()

generateFileUploadForm(string  $filetype) 

Generates upload form according to a file type

Parameters

string $filetype

imgPath()

imgPath(  $type,   $id,   $ext, boolean  $from = \Media\Service\File::FROM_ROOT) : string

Returns a path to an image file from root directory of a project (perfect choice for processing file) or from public directory (perfect choice for displaying a link) using predefined constants in Media\Service\File

Parameters

$type
$id
$ext
boolean $from

Throws

\Exception

Returns

string

sizeByType()

sizeByType(  $type) : array

Returns an array of size according to a predefined type of an image

Parameters

$type

Returns

array

getDestination()

getDestination(  $path) : string

Returns the destination directory from a given path (given path usually has file in the end)

Parameters

$path

Returns

string

getExt()

getExt(  $fileName) : string

Returns an extension of a file

Parameters

$fileName

Returns

string

buildFilePath()

buildFilePath(  $id,   $path,   $ext) : string

Returns a path to a file

Parameters

$id
$path
$ext

Returns

string

buildPath()

buildPath(  $id,   $ext) : string

Returns an end part of a file path (used in buildFilePath method)

Parameters

$id
$ext

Returns

string

moveFile()

moveFile(  $destination,   $file) : array|string

Moves a file to a directory (this method is used in writeFile method

Parameters

$destination
$file

Returns

array|string