Constants

PUBLIC_PATH

PUBLIC_PATH

UPLOADS_PATH

UPLOADS_PATH

GETPATH

GETPATH

FROM_PUBLIC

FROM_PUBLIC

FROM_ROOT

FROM_ROOT

DEFAULT_FILTER

DEFAULT_FILTER

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

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