Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
AbstractAdapter Class Reference

Abstract class for file transfers (Downloads and Uploads) More...

Public Member Functions

 send ($options=null)
 Send file.
 
 receive ($options=null)
 Receive file.
 
 isSent ($files=null)
 Is file sent?
 
 isReceived ($files=null)
 Is file received?
 
 isUploaded ($files=null)
 Has a file been uploaded ?
 
 isFiltered ($files=null)
 Has the file been filtered ?
 
 setFilterManager (FilterPluginManager $filterManager)
 Adds one or more files.
 
 getFilterManager ()
 Get the filter plugin manager instance.
 
 setValidatorManager (ValidatorPluginManager $validatorManager)
 Set the validator plugin manager instance.
 
 getValidatorManager ()
 Get the validator plugin manager instance.
 
 addValidator ($validator, $breakChainOnFailure=false, $options=null, $files=null)
 Adds a new validator for this class.
 
 addValidators (array $validators, $files=null)
 Add Multiple validators at once.
 
 setValidators (array $validators, $files=null)
 Sets a validator for the class, erasing all previous set.
 
 hasValidator ($name)
 Determine if a given validator has already been registered.
 
 getValidator ($name)
 Retrieve individual validator.
 
 getValidators ($files=null)
 Returns all set validators.
 
 removeValidator ($name)
 Remove an individual validator.
 
 clearValidators ()
 Remove all validators.
 
 setOptions ($options=[], $files=null)
 Sets Options for adapters.
 
 getOptions ($files=null)
 Returns set options for adapters or files.
 
 isValid ($files=null)
 Checks if the files are valid.
 
 getMessages ()
 Returns found validation messages.
 
 getErrors ()
 Retrieve error codes.
 
 hasErrors ()
 Are there errors registered?
 
 addFilter ($filter, $options=null, $files=null)
 Adds a new filter for this class.
 
 addFilters (array $filters, $files=null)
 Add Multiple filters at once.
 
 setFilters (array $filters, $files=null)
 Sets a filter for the class, erasing all previous set.
 
 hasFilter ($name)
 Determine if a given filter has already been registered.
 
 getFilter ($name)
 Retrieve individual filter.
 
 getFilters ($files=null)
 Returns all set filters.
 
 removeFilter ($name)
 Remove an individual filter.
 
 clearFilters ()
 Remove all filters.
 
 getFileName ($file=null, $path=true)
 Retrieves the filename of transferred files.
 
 getFileInfo ($file=null)
 Retrieve additional internal file informations for files.
 
 setDestination ($destination, $files=null)
 Sets a new destination for the given files.
 
 getDestination ($files=null)
 Retrieve destination directory value.
 
 setTranslator (Translator $translator=null, $textDomain=null)
 Sets translator to use in helper.
 
 getTranslator ()
 Retrieve localization translator object.
 
 hasTranslator ()
 Checks if the helper has a translator.
 
 setTranslatorEnabled ($flag=true)
 Indicate whether or not translation should be enabled.
 
 isTranslatorEnabled ()
 Is translation enabled?
 
 setTranslatorTextDomain ($textDomain= 'default')
 Set translation text domain.
 
 getTranslatorTextDomain ()
 Return the translation text domain.
 
 getHash ($hash= 'crc32', $files=null)
 Returns the hash for a given file.
 
 getFileSize ($files=null)
 Returns the real filesize of the file.
 
 getMimeType ($files=null)
 Returns the real mimetype of the file Uses fileinfo, when not available mime_magic and as last fallback a manual given mimetype.
 
- Public Member Functions inherited from TranslatorAwareInterface
 setTranslator (TranslatorInterface $translator=null, $textDomain=null)
 Sets translator to use in helper.
 

Public Attributes

const FILTER = 'FILTER'
 @+ Plugin loader Constants
 
const VALIDATOR = 'VALIDATOR'
 

Protected Member Functions

 detectFileSize ($value)
 Internal method to detect the size of a file.
 
 detectMimeType ($value)
 Internal method to detect the mime type of a file.
 
 filter ($files=null)
 Internal function to filter all given files.
 
 getTmpDir ()
 Determine system TMP directory and detect if we have read access.
 
 isPathWriteable ($path)
 Tries to detect if we can read and write to the given path.
 
 getFiles ($files, $names=false, $noexception=false)
 Returns found files based on internal file array and given files.
 
 getValidatorIdentifier ($name)
 Retrieve internal identifier for a named validator.
 
 getFilterIdentifier ($name)
 Retrieve internal identifier for a named filter.
 

Static Protected Member Functions

static toByteString ($size)
 Returns the formatted size.
 

Protected Attributes

 $break = []
 
 $filterManager
 
 $filters = []
 
 $loaders = []
 
 $messages = []
 
 $translator
 
 $translatorEnabled = true
 
 $translatorTextDomain = 'default'
 
 $validatorManager
 
 $validators = []
 
 $files = []
 
 $tmpDir
 
 $options
 Available options for file transfers.
 

Detailed Description

Abstract class for file transfers (Downloads and Uploads)

This class needs a full rewrite. It re-implements functionality present in Zend and/or Zend, 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.

Deprecated:
since 2.7.0, and scheduled for removal with 3.0.0

Member Function Documentation

addFilter (   $filter,
  $options = null,
  $files = null 
)

Adds a new filter for this class.

Parameters
string | Filter\FilterInterface$filterType of filter to add
string | array$optionsOptions to set for the filter
string | array$filesFiles to limit this filter to
Returns
AbstractAdapter
Exceptions
Exception\InvalidArgumentExceptionfor invalid type
addFilters ( array  $filters,
  $files = null 
)

Add Multiple filters at once.

Parameters
array$filters
string | array$files
Returns
AbstractAdapter
addValidator (   $validator,
  $breakChainOnFailure = false,
  $options = null,
  $files = null 
)

Adds a new validator for this class.

Parameters
string | Validator\ValidatorInterface$validatorType of validator to add
bool$breakChainOnFailureIf the validation chain should stop a failure
string | array$optionsOptions to set for the validator
string | array$filesFiles to limit this validator to
Returns
AbstractAdapter
Exceptions
Exception\InvalidArgumentExceptionfor invalid type
addValidators ( array  $validators,
  $files = null 
)

Add Multiple validators at once.

Parameters
array$validators
string | array$files
Returns
AbstractAdapter
Exceptions
Exception\InvalidArgumentExceptionfor invalid type
clearFilters ( )

Remove all filters.

Returns
AbstractAdapter
clearValidators ( )

Remove all validators.

Returns
AbstractAdapter
detectFileSize (   $value)
protected

Internal method to detect the size of a file.

Parameters
array$valueFile infos
Returns
string Filesize of given file
detectMimeType (   $value)
protected

Internal method to detect the mime type of a file.

Parameters
array$valueFile infos
Returns
string Mimetype of given file
filter (   $files = null)
protected

Internal function to filter all given files.

Parameters
string | array$files(Optional) Files to check
Returns
bool False on error
getDestination (   $files = null)

Retrieve destination directory value.

Parameters
null | string | array$files
Exceptions
Exception\InvalidArgumentException
Returns
null|string|array
getErrors ( )

Retrieve error codes.

Returns
array
getFileInfo (   $file = null)

Retrieve additional internal file informations for files.

Parameters
string$file(Optional) File to get informations for
Returns
array
getFileName (   $file = null,
  $path = true 
)

Retrieves the filename of transferred files.

Parameters
string$file(Optional) Element to return the filename for
bool$path(Optional) Should the path also be returned ?
Returns
string|array
getFiles (   $files,
  $names = false,
  $noexception = false 
)
protected

Returns found files based on internal file array and given files.

Parameters
string | array$files(Optional) Files to return
bool$names(Optional) Returns only names on true, else complete info
bool$noexception(Optional) Allows throwing an exception, otherwise returns an empty array
Returns
array Found files
Exceptions
Exception\RuntimeExceptionOn false filename
getFileSize (   $files = null)

Returns the real filesize of the file.

Parameters
string | array$filesFiles to get the filesize from
Returns
string|array Filesize
Exceptions
Exception\InvalidArgumentExceptionWhen the file does not exist
getFilter (   $name)

Retrieve individual filter.

Parameters
string$name
Returns
Filter|null
getFilterIdentifier (   $name)
protected

Retrieve internal identifier for a named filter.

Parameters
string$name
Returns
string
getFilterManager ( )

Get the filter plugin manager instance.

Returns
FilterPluginManager
getFilters (   $files = null)

Returns all set filters.

Parameters
string | array$files(Optional) Returns the filter for this files
Returns
array List of set filters
Exceptions
Exception\RuntimeExceptionWhen file not found
getHash (   $hash = 'crc32',
  $files = null 
)

Returns the hash for a given file.

Parameters
string$hashHash algorithm to use
string | array$filesFiles to return the hash for
Returns
string|array Hashstring
Exceptions
Exception\InvalidArgumentExceptionOn unknown hash algorithm
getMessages ( )

Returns found validation messages.

Returns
array
getMimeType (   $files = null)

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

Parameters
string | array$filesFiles to get the mimetype from
Returns
string|array MimeType
Exceptions
Exception\InvalidArgumentExceptionWhen the file does not exist
getOptions (   $files = null)

Returns set options for adapters or files.

Parameters
array$files(Optional) Files to return the options for
Returns
array Options for given files
getTmpDir ( )
protected

Determine system TMP directory and detect if we have read access.

Returns
string
Exceptions
Exception\RuntimeExceptionif unable to determine directory
getTranslator ( )

Retrieve localization translator object.

Returns
Translator|null

Implements TranslatorAwareInterface.

getTranslatorTextDomain ( )

Return the translation text domain.

Returns
string

Implements TranslatorAwareInterface.

getValidator (   $name)

Retrieve individual validator.

Parameters
string$name
Returns
Validator|null
getValidatorIdentifier (   $name)
protected

Retrieve internal identifier for a named validator.

Parameters
string$name
Returns
string
getValidatorManager ( )

Get the validator plugin manager instance.

Returns
ValidatorPluginManager
getValidators (   $files = null)

Returns all set validators.

Parameters
string | array$files(Optional) Returns the validator for this files
Returns
null|array List of set validators
hasErrors ( )

Are there errors registered?

Returns
bool
hasFilter (   $name)

Determine if a given filter has already been registered.

Parameters
string$name
Returns
bool
hasTranslator ( )

Checks if the helper has a translator.

Returns
bool

Implements TranslatorAwareInterface.

hasValidator (   $name)

Determine if a given validator has already been registered.

Parameters
string$name
Returns
bool
isFiltered (   $files = null)
abstract

Has the file been filtered ?

Parameters
array | string | null$files
Returns
bool
isPathWriteable (   $path)
protected

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

Parameters
string$path
Returns
bool
isReceived (   $files = null)
abstract

Is file received?

Parameters
array | string | null$files
Returns
bool
isSent (   $files = null)
abstract

Is file sent?

Parameters
array | string | null$files
Returns
bool
isTranslatorEnabled ( )

Is translation enabled?

Returns
bool

Implements TranslatorAwareInterface.

isUploaded (   $files = null)
abstract

Has a file been uploaded ?

Parameters
array | string | null$files
Returns
bool
isValid (   $files = null)

Checks if the files are valid.

Parameters
string | array$files(Optional) Files to check
Returns
bool True if all checks are valid
receive (   $options = null)
abstract

Receive file.

Parameters
mixed$options
Returns
bool
removeFilter (   $name)

Remove an individual filter.

Parameters
string$name
Returns
AbstractAdapter
removeValidator (   $name)

Remove an individual validator.

Parameters
string$name
Returns
AbstractAdapter
send (   $options = null)
abstract

Send file.

Parameters
mixed$options
Returns
bool
setDestination (   $destination,
  $files = null 
)

Sets a new destination for the given files.

Deprecated:
Will be changed to be a filter!!!
Parameters
string$destinationNew destination directory
string | array$filesFiles to set the new destination for
Returns
AbstractAdapter
Exceptions
Exception\InvalidArgumentExceptionwhen the given destination is not a directory or does not exist
setFilterManager ( FilterPluginManager  $filterManager)

Adds one or more files.

Parameters
string | array$fileFile to add
string | array$validatorValidators to use for this file, must be set before
string | array$filterFilters to use for this file, must be set before
Returns
AbstractAdapter
Exceptions
ExceptionNot implemented Returns all set types
Returns
array List of set types
Exceptions
ExceptionNot implemented Adds one or more type of files
Parameters
string | array$typeType of files to add
string | array$validatorValidators to use for this file, must be set before
string | array$filterFilters to use for this file, must be set before
Returns
AbstractAdapter
Exceptions
ExceptionNot implemented Returns all set files
Returns
array List of set files Set the filter plugin manager instance
Parameters
FilterPluginManager$filterManager
Returns
AbstractAdapter
setFilters ( array  $filters,
  $files = null 
)

Sets a filter for the class, erasing all previous set.

Parameters
array$filtersFilter to set
string | array$filesFiles to limit this filter to
Returns
Filter
setOptions (   $options = [],
  $files = null 
)

Sets Options for adapters.

Parameters
array$optionsOptions to set
array$files(Optional) Files to set the options for
Returns
AbstractAdapter
setTranslator ( Translator  $translator = null,
  $textDomain = null 
)

Sets translator to use in helper.

Parameters
Translator$translator[optional] translator. Default is null, which sets no translator.
string$textDomain[optional] text domain Default is null, which skips setTranslatorTextDomain
Returns
AbstractAdapter
setTranslatorEnabled (   $flag = true)

Indicate whether or not translation should be enabled.

Parameters
bool$flag
Returns
AbstractAdapter

Implements TranslatorAwareInterface.

setTranslatorTextDomain (   $textDomain = 'default')

Set translation text domain.

Parameters
string$textDomain
Returns
AbstractAdapter

Implements TranslatorAwareInterface.

setValidatorManager ( ValidatorPluginManager  $validatorManager)

Set the validator plugin manager instance.

Parameters
ValidatorPluginManager$validatorManager
Returns
AbstractAdapter
setValidators ( array  $validators,
  $files = null 
)

Sets a validator for the class, erasing all previous set.

Parameters
array$validatorsValidators to set
string | array$filesFiles to limit this validator to
Returns
AbstractAdapter
static toByteString (   $size)
staticprotected

Returns the formatted size.

Parameters
int$size
Returns
string

Member Data Documentation

$break = []
protected
$files = []
protected
$filterManager
protected
$filters = []
protected
$loaders = []
protected
$messages = []
protected
$options
protected
Initial value:
= [
'ignoreNoFile' => false

Available options for file transfers.

$tmpDir
protected
$translator
protected
$translatorEnabled = true
protected
$translatorTextDomain = 'default'
protected
$validatorManager
protected
$validators = []
protected
const FILTER = 'FILTER'

@+ Plugin loader Constants

const VALIDATOR = 'VALIDATOR'