class NamespacedAttributeBag extends AttributeBag

This class provides structured storage of session attributes using a name spacing character in the key.

Properties

protected $attributes from AttributeBag

Methods

__construct(string $storageKey = '_sf2_attributes', string $namespaceCharacter = '/')

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.

array
resolveAttributePath(string $name, bool $writeContext = false)

Resolves a path in attributes property and returns it as a reference.

string
resolveKey(string $name)

Resolves the key from the name.

Details

__construct(string $storageKey = '_sf2_attributes', string $namespaceCharacter = '/')

Parameters

string $storageKey The key used to store attributes in the session
string $namespaceCharacter Namespace character to use in keys

string getName()

Gets this bag's name.

Return Value

string

setName($name)

Parameters

$name

initialize(array $attributes)

Initializes the Bag.

Parameters

array $attributes

string getStorageKey()

Gets the storage key for this bag.

Return Value

string

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

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

set(string $name, mixed $value)

Sets an attribute.

Parameters

string $name
mixed $value

array all()

Returns attributes.

Return Value

array Attributes

replace(array $attributes)

Sets attributes.

Parameters

array $attributes Attributes

mixed remove(string $name)

Removes an attribute.

Parameters

string $name

Return Value

mixed The removed value or null when it does not exist

mixed clear()

Clears out data from bag.

Return Value

mixed Whatever data was contained

ArrayIterator getIterator()

Returns an iterator for attributes.

Return Value

ArrayIterator An \ArrayIterator instance

int count()

Returns the number of attributes.

Return Value

int The number of attributes

protected array resolveAttributePath(string $name, bool $writeContext = false)

Resolves a path in attributes property and returns it as a reference.

This method allows structured namespacing of session attributes.

Parameters

string $name Key name
bool $writeContext Write context, default false

Return Value

array

protected string resolveKey(string $name)

Resolves the key from the name.

This is the last part in a dot separated string.

Parameters

string $name

Return Value

string