File/Transfer/Adapter/Abstract.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_File_Transfer  
Version
$Id$  

\Zend_File_Transfer_Adapter_Abstract

Package: Zend_File_Transfer
Abstract class for file transfers (Downloads and Uploads)
Children
\Zend_File_Transfer_Adapter_Http
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  FILTER = 'FILTER'
>VConstant  VALIDATE = 'VALIDATE'

Properties

>VPropertyprotectedarray $_break = array()
Internal list of breaks
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_files = 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, - Internalally temporary filename for uploaded files error, - Error which has occured destination, - New destination for this file validators, - Set validator names for this file files - Set file names for this file ))
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_filters = array()
Internal list of filters
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_loaders = array()
Plugin loaders for filter and validation chains
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_messages = array()
Internal list of messages
Default valuearray()Details
Type
array
>VPropertyprotected$_options = array('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)
Available options for file transfers
Default valuearray('ignoreNoFile' => false, 'useByteString' => true, 'magicFile' => null, 'detectInfos' => true)Details
Type
n/a
>VPropertyprotectedstring $_tmpDir
TMP directory
Details
Type
string
>VPropertyprotected\Zend_Translate $_translator
Details
Type
\Zend_Translate
>VPropertyprotectedbool $_translatorDisabled = false
Is translation disabled?
Default valuefalseDetails
Type
bool
>VPropertyprotectedarray $_validators = array()
Internal list of validators
Default valuearray()Details
Type
array

Methods

methodprotected_detectFileSize(array $value) : string

Internal method to detect the size of a file

Parameters
NameTypeDescription
$valuearray

File infos

Returns
TypeDescription
stringFilesize of given file
methodprotected_detectMimeType(array $value) : string

Internal method to detect the mime type of a file

Parameters
NameTypeDescription
$valuearray

File infos

Returns
TypeDescription
stringMimetype of given file
methodprotected_filter(string | array $files = null) : boolean

Internal function to filter all given files

Parameters
NameTypeDescription
$filesstring | array

(Optional) Files to check

Returns
TypeDescription
booleanFalse on error
methodprotected_getFiles(string | array $files, boolean $names = false, boolean $noexception = false) : array

Returns found files based on internal file array and given files

Parameters
NameTypeDescription
$filesstring | array

(Optional) Files to return

$namesboolean

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

$noexceptionboolean

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

Returns
TypeDescription
arrayFound files
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionOn false filename
methodprotected_getFilterIdentifier(string $name) : string

Retrieve internal identifier for a named filter

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string
methodprotected_getTmpDir() : string

Determine system TMP directory and detect if we have read access

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_File_Transfer_Exceptionif unable to determine directory
methodprotected_getValidatorIdentifier(string $name) : string

Retrieve internal identifier for a named validator

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
string
methodprotected_isPathWriteable(string $path) : bool

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

Parameters
NameTypeDescription
$pathstring
Returns
TypeDescription
bool
methodprotected_toByteString(integer $size) : string
static

Returns the formatted size

Parameters
NameTypeDescription
$sizeinteger
Returns
TypeDescription
string
methodpublicaddFile(string | array $file, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract

Adds one or more files

Parameters
NameTypeDescription
$filestring | array

File to add

$validatorstring | array

Validators to use for this file, must be set before

$filterstring | array

Filters to use for this file, must be set before

Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionNot implemented
methodpublicaddFilter(string | array $filter, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter

Adds a new filter for this class

Parameters
NameTypeDescription
$filterstring | array

Type of filter to add

$optionsstring | array

Options to set for the filter

$filesstring | array

Files to limit this filter to

Returns
TypeDescription
\Zend_File_Transfer_Adapter
methodpublicaddFilters(array $filters, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract

Add Multiple filters at once

Parameters
NameTypeDescription
$filtersarray
$filesstring | array
Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
methodpublicaddPrefixPath(string $prefix, string $path, string $type = null) : \Zend_File_Transfer_Adapter_Abstract

Add prefix path for plugin loader

If no $type specified, assumes it is a base path for both filters and validators, and sets each according to the following rules: - filters: $prefix = $prefix . '_Filter' - validators: $prefix = $prefix . '_Validate' Otherwise, the path prefix is set on the appropriate plugin loader.
Parameters
NameTypeDescription
$prefixstring
$pathstring
$typestring
Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
Throws
ExceptionDescription
\Zend_File_Transfer_Exceptionfor invalid type
methodpublicaddPrefixPaths(array $spec) : \Zend_File_Transfer_Exception

Add many prefix paths at once

Parameters
NameTypeDescription
$specarray
Returns
TypeDescription
\Zend_File_Transfer_Exception
methodpublicaddType(string | array $type, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract

Adds one or more type of files

Parameters
NameTypeDescription
$typestring | array

Type of files to add

$validatorstring | array

Validators to use for this file, must be set before

$filterstring | array

Filters to use for this file, must be set before

Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionNot implemented
methodpublicaddValidator(string | array $validator, boolean $breakChainOnFailure = false, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter

Adds a new validator for this class

Parameters
NameTypeDescription
$validatorstring | array

Type of validator to add

$breakChainOnFailureboolean

If the validation chain should stop an failure

$optionsstring | array

Options to set for the validator

$filesstring | array

Files to limit this validator to

Returns
TypeDescription
\Zend_File_Transfer_Adapter
methodpublicaddValidators(array $validators, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract

Add Multiple validators at once

Parameters
NameTypeDescription
$validatorsarray
$filesstring | array
Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
methodpublicclearFilters() : \Zend_File_Transfer_Adapter_Abstract

Remove all filters

methodpublicclearValidators() : \Zend_File_Transfer_Adapter_Abstract

Remove all validators

methodpublicgetDestination(null | string | array $files = null) : null | string | array

Retrieve destination directory value

Parameters
NameTypeDescription
$filesnull | string | array
Returns
TypeDescription
null | string | array
Throws
ExceptionDescription
\Zend_File_Transfer_Exception
methodpublicgetErrors() : array

Retrieve error codes

Returns
TypeDescription
array
methodpublicgetFile() : array

Returns all set files

Returns
TypeDescription
arrayList of set files
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionNot implemented
methodpublicgetFileInfo(string $file = null) : array

Retrieve additional internal file informations for files

Parameters
NameTypeDescription
$filestring

(Optional) File to get informations for

Returns
TypeDescription
array
methodpublicgetFileName(string | null $file = null, boolean $path = true) : string | array

Retrieves the filename of transferred files.

Parameters
NameTypeDescription
$filestring | null
$pathboolean

(Optional) Should the path also be returned ?

Returns
TypeDescription
string | array
methodpublicgetFileSize(string | array $files = null) : string | array

Returns the real filesize of the file

Parameters
NameTypeDescription
$filesstring | array

Files to get the filesize from

Returns
TypeDescription
string | arrayFilesize
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionWhen the file does not exist
methodpublicgetFilter(string $name) : \Zend_Filter_Interface | null

Retrieve individual filter

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Filter_Interface | null
methodpublicgetFilters(string | array $files = null) : array

Returns all set filters

Parameters
NameTypeDescription
$filesstring | array

(Optional) Returns the filter for this files

Returns
TypeDescription
arrayList of set filters
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionWhen file not found
methodpublicgetHash(string $hash = 'crc32', string | array $files = null) : string | array

Returns the hash for a given file

Parameters
NameTypeDescription
$hashstring

Hash algorithm to use

$filesstring | array

Files to return the hash for

Returns
TypeDescription
string | arrayHashstring
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionOn unknown hash algorithm
methodpublicgetMessages() : array

Returns found validation messages

Returns
TypeDescription
array
methodpublicgetMimeType(string | array $files = null) : string | array

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

Parameters
NameTypeDescription
$filesstring | array

Files to get the mimetype from

Returns
TypeDescription
string | arrayMimeType
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionWhen the file does not exist
methodpublicgetOptions(array $files = null) : array

Returns set options for adapters or files

Parameters
NameTypeDescription
$filesarray

(Optional) Files to return the options for

Returns
TypeDescription
arrayOptions for given files
methodpublicgetPluginLoader(string $type) : \Zend_Loader_PluginLoader

Retrieve plugin loader for validator or filter chain

Instantiates with default rules if none available for that type. Use 'filter' or 'validate' for $type.
Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
\Zend_Loader_PluginLoader
Throws
ExceptionDescription
\Zend_File_Transfer_Exceptionon invalid type.
methodpublicgetProgress() : float
static

Retrieve progress of transfer

Returns
TypeDescription
float
methodpublicgetTranslator() : \Zend_Translate_Adapter | null

Retrieve localization translator object

Returns
TypeDescription
\Zend_Translate_Adapter | null
methodpublicgetType() : array

Returns all set types

Returns
TypeDescription
arrayList of set types
Throws
ExceptionDescription
\Zend_File_Transfer_ExceptionNot implemented
methodpublicgetValidator(string $name) : \Zend_Validate_Interface | null

Retrieve individual validator

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Validate_Interface | null
methodpublicgetValidators(string | array $files = null) : null | array

Returns all set validators

Parameters
NameTypeDescription
$filesstring | array

(Optional) Returns the validator for this files

Returns
TypeDescription
null | arrayList of set validators
methodpublichasErrors() : boolean

Are there errors registered?

Returns
TypeDescription
boolean
methodpublichasFilter(string $name) : bool

Determine if a given filter has already been registered

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
bool
methodpublichasValidator(string $name) : bool

Determine if a given validator has already been registered

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
bool
methodpublicisFiltered(array | string | null $files = null) : bool
abstract

Has the file been filtered ?

Parameters
NameTypeDescription
$filesarray | string | null
Returns
TypeDescription
bool
methodpublicisReceived(array | string | null $files = null) : bool
abstract

Is file received?

Parameters
NameTypeDescription
$filesarray | string | null
Returns
TypeDescription
bool
methodpublicisSent(array | string | null $files = null) : bool
abstract

Is file sent?

Parameters
NameTypeDescription
$filesarray | string | null
Returns
TypeDescription
bool
methodpublicisUploaded(array | string | null $files = null) : bool
abstract

Has a file been uploaded ?

Parameters
NameTypeDescription
$filesarray | string | null
Returns
TypeDescription
bool
methodpublicisValid(string | array $files = null) : boolean

Checks if the files are valid

Parameters
NameTypeDescription
$filesstring | array

(Optional) Files to check

Returns
TypeDescription
booleanTrue if all checks are valid
methodpublicreceive(mixed $options = null) : bool
abstract

Receive file

Parameters
NameTypeDescription
$optionsmixed
Returns
TypeDescription
bool
methodpublicremoveFilter(string $name) : \Zend_File_Transfer_Adapter_Abstract

Remove an individual filter

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
methodpublicremoveValidator(string $name) : \Zend_File_Transfer_Adapter_Abstract

Remove an individual validator

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
methodpublicsend(mixed $options = null) : bool
abstract

Send file

Parameters
NameTypeDescription
$optionsmixed
Returns
TypeDescription
bool
methodpublicsetDestination(string $destination, string | array $files = null) : \Zend_File_Transfer_Abstract

Sets a new destination for the given files

Parameters
NameTypeDescription
$destinationstring

New destination directory

$filesstring | array

Files to set the new destination for

Returns
TypeDescription
\Zend_File_Transfer_Abstract
Throws
ExceptionDescription
\Zend_File_Transfer_Exceptionwhen the given destination is not a directory or does not exist
Details
Deprecated
Will be changed to be a filter!!!  
methodpublicsetDisableTranslator(bool $flag) : \Zend_File_Transfer_Abstract

Indicate whether or not translation should be disabled

Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_File_Transfer_Abstract
methodpublicsetFilters( $filters, string | array $files = null) : \Zend_File_Transfer_Adapter

Sets a filter for the class, erasing all previous set

Parameters
NameTypeDescription
$filters
$filesstring | array

Files to limit this filter to

Returns
TypeDescription
\Zend_File_Transfer_Adapter
methodpublicsetOptions(array $options = array(), array $files = null) : void

Sets Options for adapters

Parameters
NameTypeDescription
$optionsarray

Options to set

$filesarray

(Optional) Files to set the options for

methodpublicsetPluginLoader(\Zend_Loader_PluginLoader_Interface $loader, string $type) : \Zend_File_Transfer_Adapter_Abstract

Set plugin loader to use for validator or filter chain

Parameters
NameTypeDescription
$loader\Zend_Loader_PluginLoader_Interface
$typestring

'filter', or 'validate'

Returns
TypeDescription
\Zend_File_Transfer_Adapter_Abstract
Throws
ExceptionDescription
\Zend_File_Transfer_Exceptionon invalid type
methodpublicsetTranslator(\Zend_Translate | null $translator = null) : \Zend_File_Transfer_Abstract

Set translator object for localization

Parameters
NameTypeDescription
$translator\Zend_Translate | null
Returns
TypeDescription
\Zend_File_Transfer_Abstract
Throws
ExceptionDescription
\Zend_File_Transfer_Exception
methodpublicsetValidators( $validators, string | array $files = null) : \Zend_File_Transfer_Adapter

Sets a validator for the class, erasing all previous set

Parameters
NameTypeDescription
$validators
$filesstring | array

Files to limit this validator to

Returns
TypeDescription
\Zend_File_Transfer_Adapter
methodpublictranslatorIsDisabled() : bool

Is translation disabled?

Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.2.0 .