Abstract class for file transfers (Downloads and Uploads)

This class needs a full rewrite. It re-implements functionality present in Zend\Filter\Input and/or Zend\Form\Element, and in a way that's inconsistent with either one. Additionally, plugin loader usage is now deprecated -- but modifying that should be done in tandem with a rewrite to utilize validator and filter chains instead.

todo Rewrite

 Methods

Adds a new filter for this class

addFilter(string | \Zend\Filter\FilterInterface $filter, string | array $options, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$filter

string\Zend\Filter\FilterInterface

Type of filter to add

$options

stringarray

Options to set for the filter

$files

stringarray

Files to limit this filter to

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException for invalid type

Returns

Add Multiple filters at once

addFilters(array $filters, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$filters

array

$files

stringarray

Returns

Adds a new validator for this class

addValidator(string | \Zend\Validator\ValidatorInterface $validator, bool $breakChainOnFailure, string | array $options, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$validator

string\Zend\Validator\ValidatorInterface

Type of validator to add

$breakChainOnFailure

bool

If the validation chain should stop a failure

$options

stringarray

Options to set for the validator

$files

stringarray

Files to limit this validator to

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException for invalid type

Returns

Add Multiple validators at once

addValidators(array $validators, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$validators

array

$files

stringarray

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException for invalid type

Returns

Retrieve destination directory value

getDestination(null | string | array $files) : null | string | array

Parameters

$files

nullstringarray

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException

Returns

nullstringarray

Retrieve error codes

getErrors() : array

Returns

array

Retrieve additional internal file informations for files

getFileInfo(string $file) : array

Parameters

$file

string

(Optional) File to get informations for

Returns

array

Retrieves the filename of transferred files.

getFileName(string $file, bool $path) : string | array

Parameters

$file

string

(Optional) Element to return the filename for

$path

bool

(Optional) Should the path also be returned ?

Returns

stringarray

Returns the real filesize of the file

getFileSize(string | array $files) : string | array

Parameters

$files

stringarray

Files to get the filesize from

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException When the file does not exist

Returns

stringarrayFilesize

Retrieve individual filter

getFilter(string $name) : \Zend\Filter\FilterInterface | null

Parameters

$name

string

Returns

Get the filter plugin manager instance

getFilterManager() : \Zend\File\Transfer\Adapter\FilterPluginManager

Returns all set filters

getFilters(string | array $files) : array

Parameters

$files

stringarray

(Optional) Returns the filter for this files

Exceptions

\Zend\File\Transfer\Exception\RuntimeException When file not found

Returns

arrayList of set filters

Returns the hash for a given file

getHash(string $hash, string | array $files) : string | array

Parameters

$hash

string

Hash algorithm to use

$files

stringarray

Files to return the hash for

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException On unknown hash algorithm

Returns

stringarrayHashstring

Returns found validation messages

getMessages() : array

Returns

array

Returns the real mimetype of the file Uses fileinfo, when not available mime_magic and as last fallback a manual given mimetype

getMimeType(string | array $files) : string | array

Parameters

$files

stringarray

Files to get the mimetype from

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException When the file does not exist

Returns

stringarrayMimeType

Returns set options for adapters or files

getOptions(array $files) : array

Parameters

$files

array

(Optional) Files to return the options for

Returns

arrayOptions for given files

Retrieve localization translator object

getTranslator() : \Zend\I18n\Translator\TranslatorInterface | null

Return the translation text domain

getTranslatorTextDomain() : string

Returns

string

Retrieve individual validator

getValidator(string $name) : \Zend\Validator\ValidatorInterface | null

Parameters

$name

string

Returns

Get the validator plugin manager instance

getValidatorManager() : \Zend\File\Transfer\Adapter\ValidatorPluginManager

Returns all set validators

getValidators(string | array $files) : null | array

Parameters

$files

stringarray

(Optional) Returns the validator for this files

Returns

nullarrayList of set validators

Are there errors registered?

hasErrors() : bool

Returns

bool

Determine if a given filter has already been registered

hasFilter(string $name) : bool

Parameters

$name

string

Returns

bool

Checks if the helper has a translator

hasTranslator() : bool

Returns

bool

Determine if a given validator has already been registered

hasValidator(string $name) : bool

Parameters

$name

string

Returns

bool

Has the file been filtered ?

isFiltered(array | string | null $files) : bool

Parameters

$files

arraystringnull

Returns

bool

Is file received?

isReceived(array | string | null $files) : bool

Parameters

$files

arraystringnull

Returns

bool

Is file sent?

isSent(array | string | null $files) : bool

Parameters

$files

arraystringnull

Returns

bool

Is translation enabled?

isTranslatorEnabled() : bool

Returns

bool

Has a file been uploaded ?

isUploaded(array | string | null $files) : bool

Parameters

$files

arraystringnull

Returns

bool

Checks if the files are valid

isValid(string | array $files) : bool

Parameters

$files

stringarray

(Optional) Files to check

Returns

boolTrue if all checks are valid

Receive file

receive(mixed $options) : bool

Parameters

$options

mixed

Returns

bool

Remove an individual filter

removeFilter(string $name) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$name

string

Returns

Remove an individual validator

removeValidator(string $name) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$name

string

Returns

Send file

send(mixed $options) : bool

Parameters

$options

mixed

Returns

bool

Sets a new destination for the given files

setDestination(string $destination, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

deprecated Will be changed to be a filter!!!

Parameters

$destination

string

New destination directory

$files

stringarray

Files to set the new destination for

Exceptions

\Zend\File\Transfer\Exception\InvalidArgumentException when the given destination is not a directory or does not exist

Returns

Set the filter plugin manager instance

setFilterManager(\Zend\File\Transfer\Adapter\FilterPluginManager $filterManager) : \Zend\File\Transfer\Adapter\AbstractAdapter

Sets a filter for the class, erasing all previous set

setFilters(array $filters, string | array $files) : \Zend\Filter\AbstractFilter

Parameters

$filters

array

Filter to set

$files

stringarray

Files to limit this filter to

Returns

Sets Options for adapters

setOptions(array $options, array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$options

array

Options to set

$files

array

(Optional) Files to set the options for

Returns

Sets translator to use in helper

setTranslator(\Zend\I18n\Translator\TranslatorInterface $translator, string $textDomain) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$translator

\Zend\I18n\Translator\TranslatorInterface

[optional] translator. Default is null, which sets no translator.

$textDomain

string

[optional] text domain Default is null, which skips setTranslatorTextDomain

Returns

Indicate whether or not translation should be enabled

setTranslatorEnabled(bool $flag) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$flag

bool

Returns

Set translation text domain

setTranslatorTextDomain(string $textDomain) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$textDomain

string

Returns

Set the validator plugin manager instance

setValidatorManager(\Zend\File\Transfer\Adapter\ValidatorPluginManager $validatorManager) : \Zend\File\Transfer\Adapter\AbstractAdapter

Sets a validator for the class, erasing all previous set

setValidators(array $validators, string | array $files) : \Zend\File\Transfer\Adapter\AbstractAdapter

Parameters

$validators

array

Validators to set

$files

stringarray

Files to limit this validator to

Returns

Internal method to detect the size of a file

detectFileSize(array $value) : string

Parameters

$value

array

File infos

Returns

stringFilesize of given file

Internal method to detect the mime type of a file

detectMimeType(array $value) : string

Parameters

$value

array

File infos

Returns

stringMimetype of given file

Internal function to filter all given files

filter(string | array $files) : bool

Parameters

$files

stringarray

(Optional) Files to check

Returns

boolFalse on error

Returns found files based on internal file array and given files

getFiles(string | array $files, bool $names, bool $noexception) : array

Parameters

$files

stringarray

(Optional) Files to return

$names

bool

(Optional) Returns only names on true, else complete info

$noexception

bool

(Optional) Allows throwing an exception, otherwise returns an empty array

Exceptions

\Zend\File\Transfer\Exception\RuntimeException On false filename

Returns

arrayFound files

Retrieve internal identifier for a named filter

getFilterIdentifier(string $name) : string

Parameters

$name

string

Returns

string

Determine system TMP directory and detect if we have read access

getTmpDir() : string

Exceptions

\Zend\File\Transfer\Exception\RuntimeException if unable to determine directory

Returns

string

Retrieve internal identifier for a named validator

getValidatorIdentifier(string $name) : string

Parameters

$name

string

Returns

string

Tries to detect if we can read and write to the given path

isPathWriteable(string $path) : bool

Parameters

$path

string

Returns

bool

Returns the formatted size

toByteString(int $size) : string

Parameters

$size

int

Returns

string

 Properties

 

Internal list of breaks

$break : array

 

Internal list of files This array looks like this: array(form => array( - Form is the name within the form or, if not set the filename name, - Original name of this file type, - Mime type of this file size, - Filesize in bytes tmp_name, - Internally temporary filename for uploaded files error, - Error which has occurred destination, - New destination for this file validators, - Set validator names for this file files - Set file names for this file ))

$files : array

 

$filterManager

$filterManager : \Zend\File\Transfer\Adapter\FilterPluginManager

 

Internal list of filters

$filters : array

 

Plugin loaders for filter and validation chains

$loaders : array

 

Internal list of messages

$messages : array

 

Available options for file transfers

$options 

 

TMP directory

$tmpDir : string

 

$translator

$translator : \Zend\I18n\Translator\TranslatorInterface

 

Is translation enabled?

$translatorEnabled : bool

 

Translator text domain (optional)

$translatorTextDomain : string

 

$validatorManager

$validatorManager : \Zend\File\Transfer\Adapter\ValidatorPluginManager

 

Internal list of validators

$validators : array

 Constants

 

FILTER

FILTER 

 

VALIDATOR

VALIDATOR