class AttributeBag implements AttributeBagInterface, IteratorAggregate, Countable

This class relates to session attribute storage.

Properties

protected $attributes

Methods

__construct(string $storageKey = '_sf2_attributes')

No description

string
getName()

Gets this bag's name.

setName($name)

No description

initialize(array $attributes)

Initializes the Bag.

string
getStorageKey()

Gets the storage key for this bag.

bool
has(string $name)

Checks if an attribute is defined.

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

Returns an attribute.

set(string $name, mixed $value)

Sets an attribute.

array
all()

Returns attributes.

replace(array $attributes)

Sets attributes.

mixed
remove(string $name)

Removes an attribute.

mixed
clear()

Clears out data from bag.

getIterator()

Returns an iterator for attributes.

int
count()

Returns the number of attributes.

Details

at line 27
__construct(string $storageKey = '_sf2_attributes')

Parameters

string $storageKey The key used to store attributes in the session

at line 35
string getName()

Gets this bag's name.

Return Value

string

at line 40
setName($name)

Parameters

$name

at line 48
initialize(array $attributes)

Initializes the Bag.

Parameters

array $attributes

at line 56
string getStorageKey()

Gets the storage key for this bag.

Return Value

string

at line 64
bool has(string $name)

Checks if an attribute is defined.

Parameters

string $name The attribute name

Return Value

bool true if the attribute is defined, false otherwise

at line 72
mixed get(string $name, mixed $default = null)

Returns an attribute.

Parameters

string $name The attribute name
mixed $default The default value if not found

Return Value

mixed

at line 80
set(string $name, mixed $value)

Sets an attribute.

Parameters

string $name
mixed $value

at line 88
array all()

Returns attributes.

Return Value

array Attributes

at line 96
replace(array $attributes)

Sets attributes.

Parameters

array $attributes Attributes

at line 107
mixed remove(string $name)

Removes an attribute.

Parameters

string $name

Return Value

mixed The removed value or null when it does not exist

at line 121
mixed clear()

Clears out data from bag.

Return Value

mixed Whatever data was contained

at line 134
ArrayIterator getIterator()

Returns an iterator for attributes.

Return Value

ArrayIterator An \ArrayIterator instance

at line 144
int count()

Returns the number of attributes.

Return Value

int The number of attributes