class FileBag extends ParameterBag

FileBag is a container for uploaded files.

Properties

protected $parameters Parameter storage. from ParameterBag

Methods

__construct(array $parameters = array())

No description

array
all()

Returns the parameters.

array
keys()

Returns the parameter keys.

replace(array $files = array())

Replaces the current parameters by a new set.

add(array $files = array())

Adds parameters.

mixed
get(string $key, mixed $default = null)

Returns a parameter by name.

set(string $key, mixed $value)

Sets a parameter by name.

bool
has(string $key)

Returns true if the parameter is defined.

remove(string $key)

Removes a parameter.

string
getAlpha(string $key, string $default = '')

Returns the alphabetic characters of the parameter value.

string
getAlnum(string $key, string $default = '')

Returns the alphabetic characters and digits of the parameter value.

string
getDigits(string $key, string $default = '')

Returns the digits of the parameter value.

int
getInt(string $key, int $default = 0)

Returns the parameter value converted to integer.

bool
getBoolean(string $key, mixed $default = false)

Returns the parameter value converted to boolean.

mixed
filter(string $key, mixed $default = null, int $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

getIterator()

Returns an iterator for parameters.

int
count()

Returns the number of parameters.

convertFileInformation(array|UploadedFile $file)

Converts uploaded files to UploadedFile instances.

array
fixPhpFilesArray($data)

Fixes a malformed PHP $_FILES array.

Details

at line 29
__construct(array $parameters = array())

Parameters

array $parameters An array of parameters

in ParameterBag at line 39
array all()

Returns the parameters.

Return Value

array An array of parameters

in ParameterBag at line 49
array keys()

Returns the parameter keys.

Return Value

array An array of parameter keys

at line 37
replace(array $files = array())

Replaces the current parameters by a new set.

Parameters

array $files

at line 58
add(array $files = array())

Adds parameters.

Parameters

array $files

in ParameterBag at line 82
mixed get(string $key, mixed $default = null)

Returns a parameter by name.

Parameters

string $key The key
mixed $default The default value if the parameter key does not exist

Return Value

mixed

at line 46
set(string $key, mixed $value)

Sets a parameter by name.

Parameters

string $key The key
mixed $value The value

in ParameterBag at line 105
bool has(string $key)

Returns true if the parameter is defined.

Parameters

string $key The key

Return Value

bool true if the parameter exists, false otherwise

in ParameterBag at line 115
remove(string $key)

Removes a parameter.

Parameters

string $key The key

in ParameterBag at line 128
string getAlpha(string $key, string $default = '')

Returns the alphabetic characters of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

in ParameterBag at line 141
string getAlnum(string $key, string $default = '')

Returns the alphabetic characters and digits of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

in ParameterBag at line 154
string getDigits(string $key, string $default = '')

Returns the digits of the parameter value.

Parameters

string $key The parameter key
string $default The default value if the parameter key does not exist

Return Value

string The filtered value

in ParameterBag at line 168
int getInt(string $key, int $default = 0)

Returns the parameter value converted to integer.

Parameters

string $key The parameter key
int $default The default value if the parameter key does not exist

Return Value

int The filtered value

in ParameterBag at line 181
bool getBoolean(string $key, mixed $default = false)

Returns the parameter value converted to boolean.

Parameters

string $key The parameter key
mixed $default The default value if the parameter key does not exist

Return Value

bool The filtered value

in ParameterBag at line 198
mixed filter(string $key, mixed $default = null, int $filter = FILTER_DEFAULT, mixed $options = array())

Filter key.

Parameters

string $key Key
mixed $default Default = null
int $filter FILTER_* constant
mixed $options Filter options

Return Value

mixed

See also

http://php.net/manual/en/function.filter-var.php

in ParameterBag at line 220
ArrayIterator getIterator()

Returns an iterator for parameters.

Return Value

ArrayIterator An \ArrayIterator instance

in ParameterBag at line 230
int count()

Returns the number of parameters.

Return Value

int The number of parameters

at line 72
protected UploadedFile[]|UploadedFile|null convertFileInformation(array|UploadedFile $file)

Converts uploaded files to UploadedFile instances.

Parameters

array|UploadedFile $file A (multi-dimensional) array of uploaded file information

Return Value

UploadedFile[]|UploadedFile|null A (multi-dimensional) array of UploadedFile instances

at line 114
protected array fixPhpFilesArray($data)

Fixes a malformed PHP $_FILES array.

PHP has a bug that the format of the $_FILES array differs, depending on whether the uploaded file fields had normal field names or array-like field names ("normal" vs. "parent[child]").

This method fixes the array to look like the "normal" $_FILES array.

It's safe to pass an already converted array, in which case this method just returns the original array unmodified.

Parameters

$data

Return Value

array