File/Transfer/Adapter/Abstract.php
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
[email protected] 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_TransferAbstract 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
Properties



array $_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



array $_loaders = array()
Plugin loaders for filter and validation chains
Default valuearray()
Details- Type
- array



array $_messages = array()
Internal list of messages
Default valuearray()
Details- Type
- array



$_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



array $_validators = array()
Internal list of validators
Default valuearray()
Details- Type
- array
Methods



_detectFileSize(array $value) : string
Internal method to detect the size of a file
ParametersName | Type | Description |
---|
$value | array | File infos |
---|
ReturnsType | Description |
---|
string | Filesize of given file |



_detectMimeType(array $value) : string
Internal method to detect the mime type of a file
ParametersName | Type | Description |
---|
$value | array | File infos |
---|
ReturnsType | Description |
---|
string | Mimetype of given file |



_filter(string | array $files = null) : boolean
Internal function to filter all given files
ParametersName | Type | Description |
---|
$files | string | array | (Optional) Files to check |
---|
ReturnsType | Description |
---|
boolean | False on error |



_getFiles(string | array $files, boolean $names = false, boolean $noexception = false) : array
Returns found files based on internal file array and given files
ParametersName | Type | Description |
---|
$files | string | array | (Optional) Files to return |
---|
$names | boolean | (Optional) Returns only names on true, else complete info |
---|
$noexception | boolean | (Optional) Allows throwing an exception, otherwise returns an empty array |
---|
ReturnsType | Description |
---|
array | Found files |
Throws 


_getFilterIdentifier(string $name) : string
Retrieve internal identifier for a named filter
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns 


_getValidatorIdentifier(string $name) : string
Retrieve internal identifier for a named validator
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns 


_isPathWriteable(string $path) : bool
Tries to detect if we can read and write to the given path
ParametersName | Type | Description |
---|
$path | string | |
---|
Returns 


_toByteString(integer $size) : string
staticReturns the formatted size
ParametersName | Type | Description |
---|
$size | integer | |
---|
Returns 


addFile(string | array $file, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract
ParametersName | Type | Description |
---|
$file | string | array | File to add |
---|
$validator | string | array | Validators to use for this file, must be set before |
---|
$filter | string | array | Filters to use for this file, must be set before |
---|
ReturnsThrows 


addFilter(string | array $filter, string | array $options = null, string | array $files = null) : \Zend_File_Transfer_Adapter
Adds a new filter for this class
ParametersName | Type | Description |
---|
$filter | string | array | Type of filter to add |
---|
$options | string | array | Options to set for the filter |
---|
$files | string | array | Files to limit this filter to |
---|
Returns 


addFilters(array $filters, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract
Add Multiple filters at once
ParametersName | Type | Description |
---|
$filters | array | |
---|
$files | string | array | |
---|
Returns 


addPrefixPath(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.
ParametersName | Type | Description |
---|
$prefix | string | |
---|
$path | string | |
---|
$type | string | |
---|
ReturnsThrows


addType(string | array $type, string | array $validator = null, string | array $filter = null) : \Zend_File_Transfer_Adapter_Abstract
Adds one or more type of files
ParametersName | Type | Description |
---|
$type | string | array | Type of files to add |
---|
$validator | string | array | Validators to use for this file, must be set before |
---|
$filter | string | array | Filters to use for this file, must be set before |
---|
ReturnsThrows 


addValidator(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
ParametersName | Type | Description |
---|
$validator | string | array | Type of validator to add |
---|
$breakChainOnFailure | boolean | If the validation chain should stop an failure |
---|
$options | string | array | Options to set for the validator |
---|
$files | string | array | Files to limit this validator to |
---|
Returns 


addValidators(array $validators, string | array $files = null) : \Zend_File_Transfer_Adapter_Abstract
Add Multiple validators at once
ParametersName | Type | Description |
---|
$validators | array | |
---|
$files | string | array | |
---|
Returns 


getDestination(null | string | array $files = null) : null | string | array
Retrieve destination directory value
ParametersName | Type | Description |
---|
$files | null | string | array | |
---|
ReturnsType | Description |
---|
null | string | array | |
Throws 


getFileInfo(string $file = null) : array
Retrieve additional internal file informations for files
ParametersName | Type | Description |
---|
$file | string | (Optional) File to get informations for |
---|
Returns 


getFileName(string | null $file = null, boolean $path = true) : string | array
Retrieves the filename of transferred files.
ParametersName | Type | Description |
---|
$file | string | null | |
---|
$path | boolean | (Optional) Should the path also be returned ? |
---|
ReturnsType | Description |
---|
string | array | |



getFileSize(string | array $files = null) : string | array
Returns the real filesize of the file
ParametersName | Type | Description |
---|
$files | string | array | Files to get the filesize from |
---|
ReturnsType | Description |
---|
string | array | Filesize |
Throws 


getFilter(string $name) : \Zend_Filter_Interface | null
Retrieve individual filter
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns 


getFilters(string | array $files = null) : array
ParametersName | Type | Description |
---|
$files | string | array | (Optional) Returns the filter for this files |
---|
ReturnsType | Description |
---|
array | List of set filters |
Throws 


getHash(string $hash = 'crc32', string | array $files = null) : string | array
Returns the hash for a given file
ParametersName | Type | Description |
---|
$hash | string | Hash algorithm to use |
---|
$files | string | array | Files to return the hash for |
---|
ReturnsType | Description |
---|
string | array | Hashstring |
Throws 


getMimeType(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
ParametersName | Type | Description |
---|
$files | string | array | Files to get the mimetype from |
---|
ReturnsType | Description |
---|
string | array | MimeType |
Throws 


getOptions(array $files = null) : array
Returns set options for adapters or files
ParametersName | Type | Description |
---|
$files | array | (Optional) Files to return the options for |
---|
ReturnsType | Description |
---|
array | Options for given files |



getPluginLoader(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.
ParametersName | Type | Description |
---|
$type | string | |
---|
ReturnsThrows


getValidator(string $name) : \Zend_Validate_Interface | null
Retrieve individual validator
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns 


getValidators(string | array $files = null) : null | array
Returns all set validators
ParametersName | Type | Description |
---|
$files | string | array | (Optional) Returns the validator for this files |
---|
ReturnsType | Description |
---|
null | array | List of set validators |



hasFilter(string $name) : bool
Determine if a given filter has already been registered
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns 


hasValidator(string $name) : bool
Determine if a given validator has already been registered
ParametersName | Type | Description |
---|
$name | string | |
---|
Returns 


isFiltered(array | string | null $files = null) : bool
abstractHas the file been filtered ?
ParametersName | Type | Description |
---|
$files | array | string | null | |
---|
Returns 


isReceived(array | string | null $files = null) : bool
abstractIs file received?
ParametersName | Type | Description |
---|
$files | array | string | null | |
---|
Returns 


isUploaded(array | string | null $files = null) : bool
abstractHas a file been uploaded ?
ParametersName | Type | Description |
---|
$files | array | string | null | |
---|
Returns 


isValid(string | array $files = null) : boolean
Checks if the files are valid
ParametersName | Type | Description |
---|
$files | string | array | (Optional) Files to check |
---|
ReturnsType | Description |
---|
boolean | True if all checks are valid |



setDestination(string $destination, string | array $files = null) : \Zend_File_Transfer_Abstract
Sets a new destination for the given files
ParametersName | Type | Description |
---|
$destination | string | New destination directory |
---|
$files | string | array | Files to set the new destination for |
---|
ReturnsThrowsDetails- Deprecated
- Will be changed to be a filter!!!



setDisableTranslator(bool $flag) : \Zend_File_Transfer_Abstract
Indicate whether or not translation should be disabled
ParametersName | Type | Description |
---|
$flag | bool | |
---|
Returns 


setFilters( $filters, string | array $files = null) : \Zend_File_Transfer_Adapter
Sets a filter for the class, erasing all previous set
ParametersName | Type | Description |
---|
$filters | | |
---|
$files | string | array | Files to limit this filter to |
---|
Returns 


setOptions(array $options = array(), array $files = null) : void
Sets Options for adapters
ParametersName | Type | Description |
---|
$options | array | Options to set |
---|
$files | array | (Optional) Files to set the options for |
---|



setValidators( $validators, string | array $files = null) : \Zend_File_Transfer_Adapter
Sets a validator for the class, erasing all previous set
ParametersName | Type | Description |
---|
$validators | | |
---|
$files | string | array | Files to limit this validator to |
---|
Returns